private void OpenNotification(Context context,Bundle bundle) { //清除所有通知 JPushInterface.ClearAllNotifications(context); //判断app进程是否存活 if (EldYoungUtil.IsApplive (context, "com.lelaozu.communitycenter")) { //如果存活的话,就直接启动报警DetailActivity,但要考虑一种情况,就是app的进程虽然仍然在 //但Task栈已经空了,比如用户点击Back键退出应用,但进程还没有被系统回收,如果直接启动 //DetailActivity,再按Back键就不会返回任何界面了。所以在启动DetailActivity前,要先启动splash界面。 Log.Info("NotificationReceiver", "the app process is alive"); Intent mainIntent = new Intent(context, typeof(MainActivity)); mainIntent.SetFlags(ActivityFlags.NewTask |ActivityFlags.SingleTop); Intent alarmDetailInfoIntent = new Intent(context, typeof(AlarmDetailInfoActivity)); bundle.PutString("alarmOrigin","Jpush"); alarmDetailInfoIntent.PutExtras (bundle); Intent[] intents = new Intent[] { mainIntent,alarmDetailInfoIntent}; context.StartActivities (intents); } else { //如果app进程已经被杀死,先重新启动app,将alarmDetailActivity的启动参数传入Intent中,参数经过 //SplashActivity传入MainActivity,此时app的初始化已经完成,在MainActivity中就可以根据传入,参数跳转到DetailActivity中去了 Log.Info("NotificationReceiver", "the app process is dead"); Intent launchIntent = context.PackageManager.GetLaunchIntentForPackage ("com.lelaozu.communitycenter"); launchIntent.SetFlags( ActivityFlags.NewTask|ActivityFlags.ResetTaskIfNeeded); bundle.PutString("alarmOrigin","Jpush"); launchIntent.PutExtras (bundle); context.StartActivity(launchIntent); } }