Android 4.2 通知通过PendingIntent启动Activity失败的问题
今天突然发现在Android 4.2手机上点击通知消息无法打开Activity的问题,具体Logcat信息如下:
01-09 11:37:43.733: WARN/ActivityManager(92): Unable to send startActivity intent
java.lang.SecurityException: Permission Denial: starting Intent { flg=0x10800000
cmp=org.goodev/.activities.ProjectActivity
bnds=[254,64][466,140] } from null (pid=-1, uid=10073) requires null
at
com.android.server.am.ActivityStack.startActivityLocked(ActivityStack.java:1973)
at
com.android.server.am.ActivityManagerService.
startActivityInPackage(ActivityManagerService.java:2271)
at
com.android.server.am.PendingIntentRecord.sendInner(PendingIntentRecord.java:212)
at
com.android.server.am.ActivityManagerService.
startActivityIntentSender(ActivityManagerService.java:2134)
at
android.app.ActivityManagerNative.onTransact(ActivityManagerNative.java:211)
at
com.android.server.am.ActivityManagerService.
onTransact(ActivityManagerService.java:1467)
at android.os.Binder.execTransact(Binder.java:320)
at dalvik.system.NativeStart.run(Native Method)
值得注意的地方用红色标示了。
研究了一下发现,该问题应该是4.2关于安全加强控制导致的。 解决该问题比较简单,在 AndroidManifest.xml 文件中 该Activity声明的地方 添加一个 “android:exported=”true”” 属性即可。
也就是说 在4.2系统中无法从外部启动一个没有exported的Activity。 而通过PendingIntent启动Activity, 启动源为系统,和被启动的应用不是一个PID。
关于exported属性的解释如下:
android:exported
Whether or not the activity can be launched by components of other applications — “true
” if it can be, and “false
” if not. If “false
“, the activity can be launched only by components of the
same application or applications with the same user ID.
The default value depends on whether the activity contains intent
filters. The absence of any filters means that the activity can be
invoked only by specifying its exact class name. This implies that the
activity is intended only for application-internal use
(since others would not know the class name). So in this case, the
default value is “false
“. On the other hand, the presence
of at least one filter implies that the activity is intended for
external use, so the default value is “true
“.
This attribute is not the only way to limit an activity’s exposure to
other applications. You can also use a permission to limit the external
entities that can invoke the activity (see the permission
attribute).
详细信息参考:http://developer.android.com/guide/topics/manifest/activity-element.html#exported
Android 4.2 通知通过PendingIntent启动Activity失败的问题的更多相关文章
- 手把手教你_怎么找android应用的包名和启动activity
自己主动化測试中常常遇到这个问题,关于这个题目,方法众多,咱的目的是找个比較简单靠谱的: 方法一: 先进入cmd窗体,adb shell 后: cd /data/data ls 能够看到包名了吧,缺点 ...
- Android应用程序内部启动Activity过程(startActivity)的源代码分析
文章转载至CSDN社区罗升阳的安卓之旅,原文地址:http://blog.csdn.net/luoshengyang/article/details/6703247 上文介绍了Android应用程序的 ...
- Android 面试必备 - 系统、App、Activity 启动过程“一锅端”
Android 系统启动过程 从系统层看: linux 系统层 Android系统服务层 Zygote 从开机启动到Home Launcher: 启动bootloader (小程序:初始化硬件) 加载 ...
- Android开机启动Activity或者Service方法
本文出自 “Bill_Hoo专栏” 博客,请务必保留此出处http://billhoo.blog.51cto.com/2337751/761230 这段时间在做Android的基础开发,现在有一需求是 ...
- Android四大组件之Activity详解——创建和启动Activity
前面我们已经对Activity有过简单的介绍: Android开发——初始Activity Android开发——响应用户事件 Android开发——Activity生命周期 先来看一下最终结果 项目 ...
- Android Intent (可通过URL启动 Activity)
Intent分为两大类: (1)显性的(Explicit) (2)隐性的(Implicit) 对于隐性意图,在某些时候, 应用程序只是想启动具有某种特征的组件, 并不想和某个特定的组件耦合. 使用In ...
- Android,配置Activity为启动Activity(AndroidManifest.xml,application,intent-filter,MAIN,LAUNCHER)
备忘: 将Activity注册为启动Activity. 在AndroidManifest.xml中的<application>元素中加入以下<activity>子元素内容: & ...
- Android启动activity的4种模式(standard、singleTop、singleTask、singleINstance)
在AndroidManifest.xml中配置activity时,android:launchMode属性会指定启动activity的模式,有四种: standard singleTop single ...
- android 25 跨进程启动activity
跨进程启动activity,启动系统预定义的activity就是跨进程的. client项目启动server项目的activity. clientActivity.java package com.s ...
随机推荐
- 七、C# 接口
并非只能通过继承使用多态性,还能通过接口使用它. 和抽象类不同,接口不包含任何实现(方法). 然后和抽象类相似,接口也定义了一系列成员,调用者可以依赖这些成员来支持一个特定的功能. 实现接口的类会 ...
- Puer是一个可以实时编辑刷新的前端服务器
##Puer是一个可以实时编辑刷新的前端服务器 确保你安装了nodejs(现在还有没nodejs环境的前端? 拖出去喂狗吧) 使用npm全局安装puer命令 npm install puer -g 输 ...
- cache—主存—辅存三级调度模拟
近日,在体系结构的课程中,老师留了一个上机作业,为cache—主存—辅存三级调度模拟,要求如下: 实现三级存储体系的模拟调度程序 描述:CPU在cache访问数据块,若命中给出对应的cache实地址, ...
- 【转】POJ题目分类
初级:基本算法:枚举:1753 2965贪心:1328 2109 2586构造:3295模拟:1068 2632 1573 2993 2996 图:最短路径:1860 3259 1062 2253 1 ...
- 手机端MVC-js框架-Gillie-中文版本
译者声明: 1.代码库发布在http://pablovallejo.github.io/gillie/ 2.查看API介绍直接戳这里看整理. Gillie是一个轻型MVC框架,受Backbone的启发 ...
- Linux中tar命令-C用法
最近写了一个项目,其中用到了tar这个命令,发现在Qt中的file取得路径之后,获得的都是绝对路径,这个时候用tar打包会将绝对路径全部放进去, 可以用tar temp.tar.gz file -C ...
- Yii2的相关学习记录,alert等美化、confirm异步、session中的flash及小部件的使用(六)
呃,系统自带的alert.confirm等弹出框实在是难看,作为一个颜控,这能忍? 这里我用的是kartik-v/yii2-dialog,这个是基于bootstrap3-dialog这个来做了一些常用 ...
- Unity扩展编辑器--类型1:Editor Windows
Extending the Editor Unity允许你使用自己定制的inspectors和Editor Windows扩展编辑器,并且你可以使用定制的Property Drawers定义属性集在i ...
- System.Web.Http.Tracing 在webapi里面应用
最近想写log.再接口里面 所以就想到了.net 4.0提供的这个类. 整好.配合asp.net api好使用 ,而且 本地调试会在 vs Output 里面输出. 1.开启这个Tracing con ...
- cf B. I.O.U.
http://codeforces.com/contest/376/problem/B #include <cstdio> #include <cstring> #includ ...