首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 移动开发 > Android >

怎么在notifications中实现恢复activity,而不是开启一个新的activity

2012-09-10 
如何在notifications中实现恢复activity,而不是开启一个新的activity?Java codelong when System.curren

如何在notifications中实现恢复activity,而不是开启一个新的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已经被系统结束掉了,那也就只有重新启动了。
[解决办法]
你的做法无法实现。。。如果把需要恢复的数据存储在文件上,首次打开读取的话貌似还是可以的。。。

热点排行