[英]Solve SecurityException: Permission Denial: starting Intent. What permission do I need?
I want to open the play store from app.我想从应用程序打开 Play 商店。 It's fine in Samsung, but it failed in OnePlus mobile.
在三星中很好,但在 OnePlus 手机中却失败了。 I don't know where does the alibaba come from.
我不知道阿里巴巴从哪里来。 It's strange.
真奇怪。
Exception java.lang.SecurityException: Permission Denial: starting Intent { act=android.intent.action.VIEW dat= http://play.google.com/ ... cmp=com.alibaba.intl.android.apps.poseidon/com.alibaba.android.intl.weex.activity.WeexPageActivity } from ProcessRecord{a1dd30c 15827:a2bliving.ie.a2b/u0a151} (pid=15827, uid=10151) not exported from uid 10156异常 java.lang.SecurityException:权限拒绝:开始意图 { act=android.intent.action.VIEW dat= http://play.google.com/ ... cmp=com.alibaba.intl.android.apps.poseidon /com.alibaba.android.intl.weex.activity.WeexPageActivity } from ProcessRecord{a1dd30c 15827:a2bliving.ie.a2b/u0a151} (pid=15827, uid=10151) 未从 uid 10156 导出
Code:代码:
private static final String PLAY_STORE_LINK = "http://play.google.com/store/apps/details?id=%s&hl=en";
public void openUpdateLink() {
context.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(getExternalAppLink())));
}
public String getExternalAppLink() {
return String.format(PLAY_STORE_LINK, context.getPackageName());
}
You need to set android:exported="true"
in your AndroidManifest.xml file您需要在 AndroidManifest.xml 文件中设置
android:exported="true"
<activity
android:name="com.anurag.example.MainActivity"
android:label="Demo"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" >
</action>
</intent-filter>
</activity>
On that device, that Intent
is getting modified to add a specific component ( com.alibaba.intl.android.apps.poseidon/com.alibaba.android.intl.weex.activity.WeexPageActivity
).在该设备上,该
Intent
正在修改以添加特定组件( com.alibaba.intl.android.apps.poseidon/com.alibaba.android.intl.weex.activity.WeexPageActivity
)。 I do not know if that is from the system chooser or something else.我不知道这是来自系统选择器还是其他什么。 And, the activity that it resolves to is not exported.
并且,它解析为的活动不会导出。
So, mostly, this is a bug in that device.因此,大多数情况下,这是该设备中的错误。
However, since the activity is not exported, there is nothing you can do to start that specific activity.但是,由于未导出活动,因此您无法启动该特定活动。
This is not a bug in your app , but a bug in the Alibaba app.这不是您的应用程序中的错误,而是阿里巴巴应用程序中的错误。 What happened was that they declared their activity WeexPageActivity to handle http/https/file schemes, but also made it not exported.
发生的事情是他们声明了他们的活动 WeexPageActivity 来处理 http/https/file 方案,但也没有将其导出。 So, every time your app tries to start an intent with one of these schemes and the Alibaba app is chosen or worse it's set as default YOUR app will crash.
因此,每次您的应用程序尝试使用这些方案之一启动 Intent 并且选择了阿里巴巴应用程序时,或者更糟的是,它被设置为默认设置,您的应用程序就会崩溃。
For instance, if you use AdMob this will happen every time a user clicks on an ad (for me the latest culprit app is mxtech.videoplayer.ActivityWebBrowser).例如,如果您使用 AdMob,每次用户点击广告时都会发生这种情况(对我来说,最新的罪魁祸首应用是 mxtech.videoplayer.ActivityWebBrowser)。
Honestly, I don't know why Android doesn't ignore said activities instead of crashing or why the other developers would make said mistake, but it is not your fault.老实说,我不知道为什么 Android 不会忽略所述活动而不是崩溃,或者为什么其他开发人员会犯所述错误,但这不是您的错。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.