android - 启动 Intent 时出现 SecurityException

标签 android android-intent

当用户点击我的状态栏通知时,应该会启动一个 Activity Intent。但是,没有任何反应,这会显示在 LogCat 中:

W/ActivityManager(   85): java.lang.SecurityException: Permission Denial: starting Intent { flg=0x20000000 cmp=cz.fhejl.pubtran.london/cz.fhejl.pubtran.PubtranMapActivity bnds=[0,152][480,248] (has extras) } from null (pid=-1, uid=10049) requires null

应用程序包为 cz.fhejl.pubtran.london,但 Activity 位于 cz.fhejl.pubtran。这是问题吗?我的应用程序基于一个库项目,这就是应用程序和 Activity 的包名称不同的原因。

最佳答案

使用

Intent notificationIntent = new Intent(getApplicationContext(), PubtranMapActivity.class);

代替

Intent notificationIntent = new Intent(this, PubtranMapActivity.class); // "this" is instance of Service

解决了这个问题。很奇怪。

关于android - 启动 Intent 时出现 SecurityException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4696626/

相关文章:

java - 使用edittext在android中以0.00格式格式化价格

Android:更新后必须重新创建应用程序快捷方式

android 支持多屏幕的最佳实践

android - 如何停止音频?

android - 如何使用默认的 android 共享( Intent )将文本共享到 facebook?

android - FLAG_ACTIVITY_REORDER_TO_FRONT 被忽略

java - 我应该用对象类型为我的变量添加后缀吗?

android - 使用 Firebase 设置群聊的阅读状态

android - 如何使用 ViewModel(MVVM) 将对象从 fragment 传递到 Activity 详细信息 View ?

android - 这是 Android 中用于应用索引的链接元素的正确格式吗?