简体   繁体   中英

Restore application when receiving broadcast

I have an application A that has a broadcast receiver. This receiver listens to certain broadcasts I get from another application B.

Now when I receive a certain broadcast from application BI want to open my application A.
At the moment I have the following code in my broadcast receiver in application A:

    @Override
    public void onReceive(Context context, Intent intent) {
     if(intent.getAction().equals("startApplication"))
        {
            Intent LaunchIntent = mContext.getPackageManager().getLaunchIntentForPackage("packageName application A");
            context.startActivity(LaunchIntent);
        }
    }

But this code always starts the main activity of application A.
When my application is already open in the background I want to restore the application rather than starting from the main activity.

Like when you press home in an application and return to it with recent apps.

Thanks!

activity级别使您的主要活动成为应用manifest中的singleInstance

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM