How to automatically Open the app without user action on receiving a push on Android

后端 未结 3 1848
轻奢々
轻奢々 2021-01-15 16:42

I am trying to open an app when a push notification is received.

Code:

public class GCMIntentService extends GCMBaseIntentService {

    public GCMIn         


        
3条回答
  •  情歌与酒
    2021-01-15 17:29

    PackageManager.getLaunchIntentForPackage can help you find the entry activity.

        Intent launchIntent = context.getPackageManager().getLaunchIntentForPackage(context.getPackageName());
        launchIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        startActivity(launchIntent);
    

提交回复
热议问题