我已经为应用程序实现了推送通知。当通知被点击时,如果应用程序已经被杀死,如何从启动屏幕启动应用程序。我想从Splash屏幕开始,如果应用程序已经被杀死,如果应用程序已经在后台,则从内部登陆屏幕开始。怎么处理这个?请帮帮我。
发布于 2016-07-21 15:47:21
将此代码添加到方法中:
Intent resultIntent = new Intent(this, SplashActivity.class);
resultIntent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT | Intent.FLAG_ACTIVITY_SINGLE_TOP);
resultIntent.setAction(Intent.ACTION_MAIN);
resultIntent.addCategory(Intent.CATEGORY_LAUNCHER);
PendingIntent resultPendingIntent = PendingIntent.getActivity(getApplicationContext(), 0, resultIntent, PendingIntent.FLAG_UPDATE_CURRENT);
mBuilder.setContentIntent(resultPendingIntent);如果您想要使用意图标志[resultIntent.addFlags(/*intent flag here*/)],请进行以下操作:
如果应用程序已经被杀死,则从Splash屏幕开始,如果应用程序已经在后台,则从内部登陆屏幕开始。
希望这能有所帮助!
发布于 2016-07-21 15:35:05
使用pendingIntent指定用户选择通知后应该执行的操作。示例教程这里
https://stackoverflow.com/questions/38508353
复制相似问题