【问题标题】:android java permissions denial manifest.xmlandroid java权限拒绝manifest.xml
【发布时间】:2011-12-25 00:22:22
【问题描述】:

您好,我正在尝试构建我的项目,但出现以下错误

ActivityManager: java.lang.SecurityException: Permission Denial: starting Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10000000 cmp=com.my_app.app/.choose_language } from null (pid=-1, uid=-1) 需要 null

我的清单文件如下

    <?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.my_app.app"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-permission android:name="android.permission.CAMERA" />
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
    <uses-permission android:name="android.permission.CALL_PHONE" />
    <uses-permission android:name="android.permission.ACCESS_CHECKIN_PROPERTIES" />


    <uses-sdk         
        android:targetSdkVersion="7" 
        android:minSdkVersion="7" 
 />

    <application
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name" >
        <activity
            android:label="@string/app_name"
            android:name=".Scan_AppActivity"
            android:screenOrientation="portrait"
            android:theme="@android:style/Theme.NoTitleBar" >

        </activity>
        <activity
            android:name=".nearby_exhibits"
            android:screenOrientation="portrait"
            android:theme="@android:style/Theme.NoTitleBar" >

        </activity>
        <activity
            android:label="@string/app_name"
            android:name=".SegmentedRadioActivity"
            android:theme="@android:style/Theme.Light" >
        </activity>
        <activity
            android:label="@string/app_name"
            android:name=".ds_main_page"
            android:screenOrientation="portrait"
            android:theme="@android:style/Theme.NoTitleBar" >

        </activity>
        <activity
            android:name=".my_scan"
            android:screenOrientation="portrait"
            android:theme="@android:style/Theme.NoTitleBar" >

        </activity>
        <activity
            android:name=".help_menu"
            android:theme="@android:style/Theme.NoTitleBar" >

        </activity>
        <activity
            android:name=".choose_language"
            android:screenOrientation="portrait"
            android:theme="@android:style/Theme.NoTitleBar" >
                             <intent-filter >
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>

        </activity>
        <activity
            android:name=".splash_screen"
            android:screenOrientation="portrait"
            android:theme="@android:style/Theme.NoTitleBar" >

        </activity>
        <activity
            android:name=".register_screen"
            android:screenOrientation="portrait"
            android:theme="@android:style/Theme.NoTitleBar" >

        </activity>
        <activity
            android:name=".login"
            android:screenOrientation="portrait"
            android:theme="@android:style/Theme.NoTitleBar" >
        </activity>
        <activity
            android:name=".attraction_more_info"
            android:screenOrientation="portrait"
            android:theme="@android:style/Theme.NoTitleBar" >

        </activity>
        <activity
            android:name="chosen_my_scan_attraction"
            android:screenOrientation="portrait"
            android:theme="@android:style/Theme.NoTitleBar" >

        </activity>
    </application>

</manifest>

如果我删除了意图过滤器部分并将其添加到我的初始屏幕活动中,我的应用程序启动正常,但在任何其他活动上使用此启动代码会引发上述错误。有谁知道这是为什么?

【问题讨论】:

    标签: java android permissions


    【解决方案1】:

    通常,requires null 中的 SecurityException 表示组件未导出。在您的情况下,这应该不是问题——当一个活动具有&lt;intent-filter&gt; 时,它会自动导出。我会确定您的应用程序中的哪个活动将具有&lt;intent-filter&gt;,并从您的设备/模拟器中完全卸载该应用程序,然后重新安装以查看这是否有帮助。

    顺便说一句,普通的 SDK 应用不能持有ACCESS_CHECKIN_PROPERTIES

    【讨论】:

    • 有见地的回答@Commons。您是如何设法找到有关与导出活动相关的requires null 的信息的?我正在努力成为一名知识渊博的 Android 开发人员,但如果我没有从 SO 上这样的答案中读到它,我永远不会建立这样的联系。另外,这是否意味着如果Activity 不包含intent-filters,那么它就不能被其他应用程序恶意/秘密调用?
    • @Turbo:“您是如何设法找到与导出活动相关的 requires null 信息的?” -- IIRC,Dianne Hackborn 在 android-developers 线程中提到了它。 “另外,这是否意味着如果一个活动不包含意图过滤器,那么它就不能被不同的应用程序恶意/秘密地调用?” -- 有一个android:exported 属性控制第三方是否可以调用该活动。拥有&lt;intent-filter&gt; 会将默认android:exported 设置为true;否则,默认为false
    • 所以只要不包含intent filter,并且android:exported标签没有设置为true,那么其他应用应该没有办法启动其他的activity吧?
    猜你喜欢
    • 2017-09-19
    • 1970-01-01
    • 2013-07-03
    • 2015-12-21
    • 2020-06-03
    • 2020-08-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多