Notification返回到当前正在运行的Activity
2011-10-02 06:41
302 查看
Notification notification=...
NotificationManager nm=...
//
Intent notificationIntent = new Intent(this,this.getClass());
PendingIntent contentIntent = PendingIntent.getActivity(this, 0,notificationIntent,PendingIntent.FLAG_UPDATE_CURRENT);
nm.notify(1, notification);
new Intent(this,this.getClass())保证了点击通知栏里的通知可以回到该Activity
但是,假如该Activity还在后台运行,并没有运行,通知事件响应后,系统会自动结束该Activity,然后再重新启动Activity,这不是我们要的。
解决方法为:在manifest.xml文件中找到该Activity,添加属性android:launchMode="singleTask“。这个属性很明显,就是只允许有一个该Activity运行,如果正在运行,则只能切换到当前运行的Activity,而不能重新启动Activity。
NotificationManager nm=...
//
Intent notificationIntent = new Intent(this,this.getClass());
PendingIntent contentIntent = PendingIntent.getActivity(this, 0,notificationIntent,PendingIntent.FLAG_UPDATE_CURRENT);
nm.notify(1, notification);
new Intent(this,this.getClass())保证了点击通知栏里的通知可以回到该Activity
但是,假如该Activity还在后台运行,并没有运行,通知事件响应后,系统会自动结束该Activity,然后再重新启动Activity,这不是我们要的。
解决方法为:在manifest.xml文件中找到该Activity,添加属性android:launchMode="singleTask“。这个属性很明显,就是只允许有一个该Activity运行,如果正在运行,则只能切换到当前运行的Activity,而不能重新启动Activity。
相关文章推荐
- Notification返回到当前正在运行的Activity
- 状态栏返回到当前正在运行的Activity
- android服务里生成通知点击后返回正在运行的程序和当前的Activity
- Android中实现“程序前后台切换效果”和“返回正在运行的程序,而不是一个新Activity”
- 查看当前正在运行的Activity列表
- Android中实现“程序前后台切换效果”和“返回正在运行的程序,而不是一个新Activity”
- Android点击通知栏信息后返回正在运行的程序,而不是一个新Activity
- Android中实现“程序前后台切换效果”和“返回正在运行的程序,而不是一个新Activity”
- 获取当前正在运行的应用程序的包名以及入口activity
- Android-如何获得当前正在运行的activity和进程的相关信息
- Android中实现“程序前后台切换效果”和“返回正在运行的程序,而不是一个新Activity”
- 获取当前界面正在当前运行的Activity的名字
- android-如何获得当前正在运行的activity的相关信息
- 点击Notification跳转到正在运行的activity
- android 获取当前正在运行的activity
- 获取当前正在运行的Activity
- Notification(三)——点Notification后返回当前App所在的Activity
- Android获得当前正在运行的Activity及相关信息
- 使用adb获取当前正在运行的Activity
- 通过Adb 查看当前正在运行的Activity.