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 6546145
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T11:40:20+00:00 2026-05-25T11:40:20+00:00

I am trying to launch an activity in the onPostExecute method of an AsyncTask.

  • 0

I am trying to launch an activity in the onPostExecute method of an AsyncTask. This async class is implemented in another class which dosent extends an activity. But I am passing application context as an argument to the method in this class.
Here is the sample code

@Override
        protected void onPostExecute(String result) 
        {
            try
            {
                System.out.println("Response : "+result);
                Toast.makeText(context, "Account Successfully Created", Toast.LENGTH_LONG).show();
                Intent intent = new Intent(context,OperationPanelActivity.class);
                context.startActivity(intent);
             }
             catch(Exception e)
             {
                   Log.d("Error: ", e.getMessage());
             }
        }

Inside this class I am taking the application context like this

public void createUser(String userName,String password,String firstName,String lastName,String email,Context context)
    {
        InvokeWebService service = new InvokeWebService();
        CALL_URL = Global.SERVICE_URL+"createuserget";
        this.context = context;
        service.execute(new String[] {userName,password,firstName,lastName,email});
    }

But the new activity is not getting invoked.

How can I do this in android?
Thanks

  • 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-05-25T11:40:20+00:00Added an answer on May 25, 2026 at 11:40 am

    This is because your activity could be finished by the time you run onPostExecute. You should notify the activity somehow and let the activity start the new activity

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

Sidebar

Related Questions

I am simply trying to launch an activity from a button but when I
Im trying to link up the array[1] to launch an activity but its showing
I am trying to launch a dialogue from a non activity java class. Can
I have an activity (DemoAppActivity) from which I am trying to launch a different
I'm trying to launch an activity , when i got an incoming call for
I'm trying to launch another process from a service (it's a console app that
I'm trying to launch my ClickOnce application using C# code with HttpWebRequest class. The
I'm trying to launch another application from C# application, is there a way to
I am trying to launch the Main Activity from a broadcast receiver. Can anyone
I'm trying to launch add contact activity from my application. I've known how to

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.