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:exportedWhether 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 ...
随机推荐
- 三、T4模板与实体生成
上文我们最后虽然用模板创建了一个实体类,但是类的内容仍旧是静态的,这里我们需要用动态方式生成类的内容.因为需要查询数据库这里又免不了各种繁琐的连接数据库操作,为了使我们的编码更加直观,仍然采 ...
- 使用第三方框架 Masonry 实现自动布局
使用第三方框架 Masonry 实现自动布局 时间:2015-02-10 11:08:41 阅读:4595 评论:0 收藏:0 [点我收藏+] 标签: 由于前两 ...
- 用core dump来调试程序段错误
有的程序可以通过编译, 但在运行时会出现Segment fault(段错误). 这通常都是指针错误引起的.但这不像编译错误一样会提示到文件->行, 而是没有任何信息, 使得我们的调试变得困难起来 ...
- interrupt & storage & DMA
1.Interrupt: The occurrence of an event is usually signaled by aninterrupt from either the hardware ...
- Tweet button with a callback – How to?
原文: http://jaspreetchahal.org/tweet-button-with-a-callback-how-to/ 两种方式:1. 原生的button <a href=&quo ...
- 织梦dede标签tags的美化教程
我们在行dede仿站的时候,经常会遇到tags标签的调用,调用非常简单,官方有专门的调用标签,但是官方的调用是一成不变的模式,dede5.6以前的版本,基本上都是黑色相同大小的表示,而在dede5.7 ...
- 给AVS添加描述(how to add a description to a video)
UPDATE you might need edit few files. 1. add the input field to the tpl file: /templates/frontend/yo ...
- 01:Hello, World!
描述 对于大部分编程语言来说,编写一个能够输出“Hello, World!”的程序往往是最基本.最简单的.因此,这个程序常常作为一个初学者接触一门新的编程语言所写的第一个程序,也经常用来测试开发.编译 ...
- 驱动读写进程内存R3,R0通信
stdafx.h 头文件代码 #ifndef _WIN32_WINNT // Allow use of features specific to Windows XP or later. #defin ...
- insert 和 if x is not None
insert(位置,元素) #!/usr/bin/python aList = [123, 'xyz', 'zara', 'abc'] aList.insert( 3, 2009) print &qu ...