日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 运维知识 > Android >内容正文

Android

Android 4.2 通知通过PendingIntent启动Activity失败的问题

發布時間:2023/12/13 Android 34 豆豆
生活随笔 收集整理的這篇文章主要介紹了 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

轉載于:https://www.cnblogs.com/Free-Thinker/p/3977494.html

總結

以上是生活随笔為你收集整理的Android 4.2 通知通过PendingIntent启动Activity失败的问题的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。