当用户点击我的状态栏通知时,应该会启动一个 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/