简体   繁体   English

java.lang.SecurityException:权限拒绝:启动Intent com.android.calendar / .DayActivity

[英]java.lang.SecurityException: Permission Denial: starting Intent com.android.calendar/.DayActivity

In my app I use the following code to open standard android calendar on the DayView: 在我的应用中,我使用以下代码在DayView上打开标准android日历:

Intent intent2 = new Intent();
intent2.setComponent(new ComponentName("com.android.calendar", "com.android.calendar.DayActivity"));
intent2.setAction("android.intent.action.MAIN");
intent2.addCategory("android.intent.category.LAUNCHER");
intent2.setFlags(0x10200000);
intent2.putExtra("beginTime", (new Time()).setJulianDay(reqDay));
intent2.putExtra("DETAIL_VIEW", true);
intent2.putExtra("DETAIL_VIEW_MODE", 2);
context.startActivity(intent2);

This used to work perfectly fine - and still is working perfectly fine on most handsets. 过去,它的工作原理非常好-大部分手机仍然可以正常工作。 However on one phone (Android 2.3 - CM7) yesterday I started receiving this error (line breaks added for readability): 但是昨天在一部手机(Android 2.3-CM7)上,我开始收到此错误(为便于阅读而添加了换行符):

Permission Denial: starting Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER]
flg=0x10200000 cmp=com.android.calendar/.DayActivity (has extras) }
from ProcessRecord{407719a0 3244:com.lge.android.calendarwidget/10077}
(pid=3244, uid=10077) requires null

The full error from the log cat is below: 日志猫的完整错误如下:

I/ActivityManager(  245): Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=com.android.calendar/.DayActivity (has extras) } from pid 3244
W/ActivityManager(  245): Permission denied: checkComponentPermission() reqUid=10004
W/ActivityManager(  245): Permission Denial: starting Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=com.android.calendar/.DayActivity (has extras) } from ProcessRecord{407719a0 3244:com.lge.android.calendarwidget/10077} (pid=3244, uid=10077) requires null
W/calw3   ( 3244): com.android.calendar not found, trying com.google.android.calendar
W/calw3   ( 3244): java.lang.SecurityException: Permission Denial: starting Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=com.android.calendar/.DayActivity (has extras) } from ProcessRecord{407719a0 3244:com.lge.android.calendarwidget/10077} (pid=3244, uid=10077) requires null

Two questions I have: (1) Why did it break all of a sudden? 我有两个问题:(1)为什么突然中断了? It definitely worked on this phone before (this is my main phone); 肯定以前在这部手机上工作过(这是我的主手机); and (2) how can I fix it? 和(2)如何解决?

EDIT Just to add that this same code is still working perfectly fine on another phone I own (HTC Desire X). 编辑只是要补充一点,在我拥有的另一部手机(HTC Desire X)上,相同的代码仍然可以正常工作。

(1) Why did it break all of a sudden? (1)为什么突然中断了? It definitely worked on this phone before (this is my main phone) 以前肯定在这部手机上有效(这是我的主手机)

That application was upgraded, perhaps as part of a firmware upgrade, and that activity is no longer exported. 该应用程序已升级,可能是固件升级的一部分,并且该活动不再导出。

(2) how can I fix it? (2)如何解决?

Delete the code. 删除代码。 You cannot start a private (non-exported) activity. 您无法启动私人(未导出)活动。 Perhaps consider using CalendarContract to roll your own version of this activity, if that API supports whatever that activity did. 如果该API支持该活动执行的任何操作,则可以考虑使用CalendarContract滚动此活动的您自己的版本。

You shouldn't have been invoking undocumented activities in this app in the first place, as there was no guarantee that the app would exist on all devices, or support that activity on all devices. 首先,您不应该在此应用程序中调用未记录的活动,因为不能保证该应用程序将存在于所有设备上,或支持所有设备上的活动。 Your current state of affairs is just another, concrete manifestation of this problem. 您当前的状况只是该问题的另一种具体体现。

很奇怪,之前一切都很好,我不得不问,您在android manifest中有这行吗?:

 <uses-permission android:name="android.permission.READ_CALENDAR"/>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Android - java.lang.SecurityException:权限拒绝:启动 Intent - Android - java.lang.SecurityException: Permission Denial: starting Intent 不正确的Activity java.lang.SecurityException:Permission Denial:启动Intent - Not the right Activity java.lang.SecurityException: Permission Denial: starting Intent java.lang.SecurityException:权限拒绝:启动意图 - java.lang.SecurityException: Permission Denial: starting Intent java.lang.SecurityException:Permission Denial:启动Intent - java.lang.SecurityException: Permission Denial: starting Intent java.lang.SecurityException:Permission Denial:启动Intent {flg = 0x800000 cmp = com.android.systemui / .recents.RecentsActivity - java.lang.SecurityException: Permission Denial: starting Intent { flg=0x800000 cmp=com.android.systemui/.recents.RecentsActivity ActivityManager:java.lang.SecurityException:权限拒绝:启动Intent {act = android.intent.act - ActivityManager: java.lang.SecurityException: Permission Denial: starting Intent { act=android.intent.act Android:java.lang.SecurityException:权限拒绝:启动意图 - Android: java.lang.SecurityException: Permission Denial: start Intent “java.lang.SecurityException:权限拒绝:启动意图”在Android上发送电子邮件 - “java.lang.SecurityException: Permission Denial: starting Intent” sending an email on Android java.lang.SecurityException:权限拒绝:启动意图{act = android.settings.USAGE_ACCESS_SETTINGS} - java.lang.SecurityException: Permission Denial: starting Intent {act=android.settings.USAGE_ACCESS_SETTINGS} java.lang.SecurityException:权限拒绝:打开提供程序 com.android.providers.calendar.CalendarProvider2 - java.lang.SecurityException: Permission Denial: opening provider com.android.providers.calendar.CalendarProvider2
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM