Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8852679
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T13:27:41+00:00 2026-06-14T13:27:41+00:00

Somehow, I can’t get this done. This is all what I tried till now:

  • 0

Somehow, I can’t get this done. This is all what I tried till now:

  1. Main:

    private String myState;
    
    public String getState() {
        return myState;
    }
    
    public void setState(String s) {
        myState = s;
    }
    

    Async:

    Main appState = ((Main)getApplicationContext());
    String state = appState.getState();
    

    Error: No enclosing instance of the type Main is accessible in scope

  2. Tried with Helper(Globals) class.

    public class Globals extends Application{
          private String test= "1";
    }
    

    Main:

    private Globals mGlobals;
    mGlobals = new Globals();  
    mGlobals.test = "2";
    //Do Async thing
    

    Async:

    private Globals mGlobals;
    mGlobals = new Globals();
    print mGlobals.test;
    // (result is 1, should be 2)
    
  3. Also something else, but don’t remember good.
    Tried alot of things (backspace and del buttons are over-used :p )
    But I can’t get everything working.

    Async class doesn’t have an activity.

Code pasted: http://pastebin.com/ikcsdL1p

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T13:27:43+00:00Added an answer on June 14, 2026 at 1:27 pm

    Instead of trying to get Application Context , try to pass Context directly in AsyncTask Constructor. as @Mohd Mufiz already mentioned in his Answer.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've been working all day and I somehow can't get this probably easy task
Somehow I can't seem to get string replacement within a foreach loop in C#
I somehow can't get this to work. I want at least one name but
Can I get somehow(from a database or other source) a percentage of the phones
This should be simple, but somehow I can't find a way to create simple
My problem is probably quite simple, but somehow I can’t get it fixed. In
Somehow I can't manage to get an imageview to be on top of a
I had this almost working several hours ago, but I can't seem to get
Somehow I can't get my UTF-8 sources to play nice with Ant. I get
Ok for sure this has been asked and answered already but i somehow can't

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.