从Notification启动intent导致新建Activity的问题【已解决】
来源:互联网 发布:手机淘宝怎样帮人代付 编辑:程序博客网 时间:2024/06/08 00:19
问题描述:
尝试过的方法:
- 1.即使在清单文件里面设置了启动方式为单一任务,或者单例,居然还执行onCreate(说明 framwork层代码有问题);
- 2.采取过的策略(均无效):
- 1.模仿界面快捷方式的启动(没找到)。
- 2.想通过屏蔽home键位,然后keyCode赋值为back等效,无效(5.1以上目前暂未找到屏蔽home键位方法,下一步再研究)。
- 3.在notification想通过intent传值过去,onCreate得到后就关闭,发现传不过去。
- 4.也用了单例工具类管理所有的Activity,create一个就记录,后面全部删除。
- 5.也重写了onBackpress(),执行,但后面产生bug(关闭后,录音停止等…)
最终解决策略:
- 1.Notification里的Intent采取了另外的写法,如下:
Intent intent = new Intent(Intent.ACTION_MAIN);intent.addCategory(Intent.CATEGORY_LEANBACK_LAUNCHER);intent.setClass(this, SoundRecorder.class);
- (PS:三者缺一不可,顺序必须如此)
- 2.下列写法无效:
Intent intent = new Intent(this, SoundRecorder.class);intent.addCategory(Intent.CATEGORY_LEANBACK_LAUNCHER);
- 理解:因为声明了意图和类型之后,才再设置跳转的类,才会生效。
- 参数的意义是:leanback_launcher:意思是,启动的时候,选择上个栈的意思(即启动上一个栈)
总结:其实如果framework层正常的话那么只需清单文件注册即可。用不着上面各种配置。先已经成功解决,Notification里直接new Intent(this,XXX.class)
0 0
- 从Notification启动intent导致新建Activity的问题【已解决】
- 使用Intent启动Activity 的问题
- 从Service中的Notification启动Activity
- Android 新建activity的intent 的flag
- Intent启动Activity的Flag
- 360Replugin插件启动Activity慢导致ANR的问题
- [已解决] 收到广播无法启动activity
- Activity已singleTask启动,intent传值得解决办法
- 隐式Intent启动Activity不成功问题
- Andorid Notification--不用启动Activity的通知
- Andorid Notification--不用启动Activity的通知
- Eclipse之新建Activity自动导入v7包导致报错的问题
- 从serivce中通过Notification启动一个Activity
- 从serivce中通过Notification启动一个Activity
- WebApp由于需要从Spring官网下载schema文件导致启动时长时间卡住问题的分析和解决
- 跨App启动Activity,隐式Intent启动,ActivityNotFoundException解决
- 关于Android使用隐式启动Activity报No Activity found to handle Intent的问题
- android开发中是用Intent从一个activity跳向一个activity的问题
- UNREAL ENGINE 4 BUILD FILE DEMYSTIFIED
- 银行卡四元素实名认证
- Android应用出错 error: Error retrieving parent for item: No resource found that matches the given name
- mysql学习笔记_覆盖索引
- C++ STL--stack/queue 的使用方法
- 从Notification启动intent导致新建Activity的问题【已解决】
- base64解码后转成图片到本地
- android interpolator 学习
- web前端 页面性能优化小结
- classLoad疑惑
- oracle备份报error 12541错解决方法
- java注解(Annotation)
- 有关visual中常见的error lnk错误收集
- POJ 3254 Corn Fields (状压DP)