android 点击快捷方式提示未安装程序的解决

原博客链接

最近APP出现一个很奇怪的问题,在Android 4.4.2和android 4.4.3系统上点击应用的快捷方式,打不开应用,而且会提示未安装程序。

确认了应用的MainActivity中设置了android.intent.action.MAIN,添加了INSTALL_SHORTCUT的权限,并且快捷方式的Intent是指向正确的Activity,原因就一直没找到。后来分析了一下在点击快捷方式时的log,发现了这么一句:

[plain]  view plain  copy
  1. W/ActivityManager(  770): Permission Denial: starting Intent { act=android.intent.action.MAIN flg=0x10000000 cmp=com.dudaogame.gamecenter/.MainActivity bnds=[14,423][266,738] } from ProcessRecord{4389cfe8 1293:com.sec.android.app.launcher/u0a9} (pid=1293, uid=10009) not exported from uid 10242  

log的意思是说不能app的进程不能被其他进程(这里指的是com.sec.android.app.launcher,即手机的launcher应用)调用。解决方法就是在MainActivity的属性中添加exported="true"。

-------------以上原博客内容

我的是在Android 6.0 系统上,有两个Activity,当把shortCut设置为启动Maintivity,一切正常,当把shortCut设置为OthersActivity,就报错,“未安装该应用!”在

OthersActivity的清单文件中,添加属性exported="true"就OK了。

猜你喜欢

转载自blog.csdn.net/qq_32227681/article/details/75221490