java - 解决SecurityException : Permission Denial: starting Intent. 我需要什么权限?

标签 java android android-intent

我想从应用程序打开 Play 商店。在三星还好,在一加手机就失败了。 我不知道 alibaba 是从哪里来的。很奇怪。

异常 java.lang.SecurityException:权限被拒绝:启动 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 } 来自 ProcessRecord{a1dd30c 15827:a2bliving.ie.a2b/u0a151} (pid=15827, uid=10151) 不是从 uid 10156 导出的

代码:

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());
    }

最佳答案

您需要在 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>

关于java - 解决SecurityException : Permission Denial: starting Intent. 我需要什么权限?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41963980/

相关文章:

android - 拒绝在没有用户手势的情况下启动 Intent Webview Android

java - 双链表中删除方法内部的未知 for 循环?

java - JVM 在 CompilerThread 崩溃

java - 计算 xsl :result-document in a given stylesheet 的所有出现次数

android自定义组 View 布局不正确

java - Viewpager 标签 fragment 和普通 fragment

android - 如何在 Android 中拦截谷歌地图 Intent ?

java - Java是“按引用传递”还是“按值传递”?

java - 如何在没有重复代码的情况下使用抽屉导航?

Android:使用 Intent Url 方案显式调用 Activity