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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T10:40:10+00:00 2026-05-23T10:40:10+00:00

I want to use AsyncTask to call another application. I have a main app

  • 0

I want to use AsyncTask to call another application. I have a main app that does its own thing but when I launch it, it does an AsyncTask to call a “messages” application which checks to see if there are any unread messages and then displays a notification in the status bar.

However, when I called execute(), the messages application jumps to the front and I have to press the back button to get to my main application.

Code is as follows (my main application)

protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    MessageUpdate update = new MessageUpdate(this);
    System.out.println("Calling Update");
    update.execute(null);
....

My AsyncTask:

public class MessageUpdate extends AsyncTask{

    Context ctx;
    public MessageUpdate(Context ctx){
        this.ctx = ctx;
    }

    @Override
    protected Object doInBackground(Object... params) {
        Intent notificationIntent = new Intent();
        notificationIntent.setClassName("com.test.messages", "com.test.messages.MessageCheck");
        ctx.startActivity(notificationIntent);
        return null;
    }
}

Can anyone tell my why the MessagesCheck jumps to the front and how to stop it? Or if what I’m doing is even feasible?

  • 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-23T10:40:10+00:00Added an answer on May 23, 2026 at 10:40 am

    As others have pointed out, a service is the way to go. However, if you use bindService() the service will only last as long as it’s bound.

    Just to clarify some of the issues:

    • Using startActivity to communicate with a background task is not what you want, as an Activity is a user interface component, which will come to the front when activated.
    • The suggestion is that you add a service to your “messages” application, not the main application.
    • You can then communicate with the “messages” application from the main application by binding to the service. If you do this (using bindService), the service will not run indefinitely.
    • The details of how to do this are here.

    You could do all this without an AsyncTask, however it may help to avoid blocking the UI thread if the service takes significant time to do its job. Alternatively, your service could use a background thread of its own to check for messages and post the notification.

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

Sidebar

Related Questions

I am using AsyncTask and want to use getApplication() to work with class Application.
I want use JQuery mobile for the front-end of my mobile application, but I
I want to use BroadcastReceiver in my application as AsyncTask result indicator in different
I have a service that performs a slow task, when its finished I want
I have AsyncTask extend class I want to display progress dialoge so I use
I want to lock back button while my data process. I use AsyncTask to
I want use BYTE_ORDER macro in my Xcode project but i can't because i
i want use some data from a website with web service. i have a
I use an AsyncTask for loading operations that I implemented as an inner class.
My main application does this: It retrievs data from the internet and has 3

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.