Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/191.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用android时的困惑:android.permission.RECEIVE_BOOT_的权限已完成_Android_Broadcastreceiver_Android Permissions - Fatal编程技术网

使用android时的困惑:android.permission.RECEIVE_BOOT_的权限已完成

使用android时的困惑:android.permission.RECEIVE_BOOT_的权限已完成,android,broadcastreceiver,android-permissions,Android,Broadcastreceiver,Android Permissions,请查看以下Maniferst.xml文件 <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="pack.saltriver" android:versionCode="1" android:versionName="1.0" android:permission=

请查看以下Maniferst.xml文件

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


   <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"></uses-permission>

    <application android:icon="@drawable/icon" android:label="@string/app_name">

        <receiver android:name=".autostart">
            <intent-filter>
                <action android:name="android.intent.action.BOOT_COMPLETED" />
            </intent-filter>
        </receiver>

        <activity android:name=".hello"></activity>
        <service android:enabled="true" android:name=".service" />
    </application>
 </manifest>



它们之间有什么区别?

不,像这样更改您的清单

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


   <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"></uses-permission>

    <application android:icon="@drawable/icon" android:label="@string/app_name">

        <receiver android:name=".autostart">
            <intent-filter>
                <action android:name="android.intent.action.BOOT_COMPLETED" />
            </intent-filter>
        </receiver>

        <activity android:name=".hello"></activity>
        <service android:enabled="true" android:name=".service" />
    </application>
 </manifest>

声明可用于限制对此应用程序或其他应用程序的特定组件或功能的访问的安全权限

因此,由于您正在访问Android的权限,因此您希望使用权限。此元素的文档说明:

请求必须授予应用程序的权限,以使其正确运行


通常在创建自定义权限时使用(例如,在创建其他应用程序可以连接的应用程序时,必须限制访问权限),并且在应用程序实际需要通常不具有的权限时使用。

使用权限仅够,不需要在清单标记中写入权限

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



   <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"></uses-permission>

    <application android:icon="@drawable/icon" android:label="@string/app_name">

        <receiver android:name=".autostart">
            <intent-filter>
                <action android:name="android.intent.action.BOOT_COMPLETED" />
            </intent-filter>
        </receiver>

        <activity android:name=".hello"></activity>
        <service android:enabled="true" android:name=".service" />
    </application>
 </manifest>


我认为不需要此权限:android:permission=“android.permission.RECEIVE\u BOOT\u COMPLETED”与论坛网站不同,我们不使用“谢谢”、“感谢任何帮助”或签名。见”。
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="pack.saltriver" 
    android:versionCode="1" 
    android:versionName="1.0">


   <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"></uses-permission>

    <application android:icon="@drawable/icon" android:label="@string/app_name">

        <receiver android:name=".autostart">
            <intent-filter>
                <action android:name="android.intent.action.BOOT_COMPLETED" />
            </intent-filter>
        </receiver>

        <activity android:name=".hello"></activity>
        <service android:enabled="true" android:name=".service" />
    </application>
 </manifest>
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="pack.saltriver" 
    android:versionCode="1" 
    android:versionName="1.0">



   <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"></uses-permission>

    <application android:icon="@drawable/icon" android:label="@string/app_name">

        <receiver android:name=".autostart">
            <intent-filter>
                <action android:name="android.intent.action.BOOT_COMPLETED" />
            </intent-filter>
        </receiver>

        <activity android:name=".hello"></activity>
        <service android:enabled="true" android:name=".service" />
    </application>
 </manifest>