怎么在notifications中实现恢复activity,而不是开启一个新的activity
如何在notifications中实现恢复activity,而不是开启一个新的activity?
这个要怎么改啊?我点击消息图标进去后,结果还是执行了onCreate方法,如何实现让他不知道oncreate,而是onRestart()
------解决方案--------------------
在AndroidManifext.xml里面设置指定的Activity的启动方式android:launchMode="singleInstance"
这样就不会重新启动,但如果Activity已经被系统结束掉了,那也就只有重新启动了。
------解决方案--------------------
你的做法无法实现。。。如果把需要恢复的数据存储在文件上,首次打开读取的话貌似还是可以的。。。
- Java code
long when = System.currentTimeMillis(); Notification notification = new Notification(R.drawable.mark,"", when); notification.flags |= Notification.FLAG_NO_CLEAR|Notification.FLAG_ONGOING_EVENT; Intent notificationIntent = new Intent(Intent.ACTION_MAIN); notificationIntent.setClass(this, MainActivity.class); notificationIntent.addCategory(Intent.CATEGORY_HOME); notificationIntent.addFlags(Intent.action_) notificationIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); PendingIntent contentIntent = PendingIntent.getActivity(this,1, notificationIntent,PendingIntent.FLAG_UPDATE_CURRENT); notification.setLatestEventInfo(this,getResources().getString(R.string.app_name),"xxxxxx",contentIntent); mNotificationManager.notify(R.drawable.mark, notification);
这个要怎么改啊?我点击消息图标进去后,结果还是执行了onCreate方法,如何实现让他不知道oncreate,而是onRestart()
------解决方案--------------------
在AndroidManifext.xml里面设置指定的Activity的启动方式android:launchMode="singleInstance"
这样就不会重新启动,但如果Activity已经被系统结束掉了,那也就只有重新启动了。
------解决方案--------------------
你的做法无法实现。。。如果把需要恢复的数据存储在文件上,首次打开读取的话貌似还是可以的。。。