1

我有一个启动完整的广播接收器,但它没有按预期工作。也不是需要 STATUS_BAR 权限的全屏活动。

我试图在手机启动时查看 LogCat 日志,这就是我发现的:

日志

 04-11 14:23:48.718: W/PackageManager(133): Not granting permission 
    android.permission.BIND_DEVICE_ADMIN to package com.myprojects.myapp (protectionLevel=2 flags=0xbe46)

任何线索为什么会发生这种情况?

我的清单文件有:

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

<receiver android:name="com.myprojects.myapp.DeviceAdministrationReceiver"
        android:permission="android.permission.BIND_DEVICE_ADMIN">  
       <meta-data android:name="android.app.device_admin" android:resource="@xml/device_admin_policies" />

    <intent-filter>
            <action android:name="android.app.action.DEVICE_ADMIN_ENABLED" />
    </intent-filter>
</receiver>

<receiver android:name="com.myprojects.myapp.BootCompleteReceiver">  
        <intent-filter>  
            <action android:name="android.intent.action.BOOT_COMPLETED" />  
        </intent-filter>  
</receiver>

编辑 和其他两个类似的日志:

04-11 14:24:17.810: W/PackageManager(133): Not granting permission android.permission.STATUS_BAR to package com.myprojects.myapp (protectionLevel=3 flags=0xbe46)

04-11 14:24:17.810: W/PackageManager(133): Not granting permission android.permission.WRITE_SECURE_SETTINGS to package com.myprojects.myapp (protectionLevel=3 flags=0xbe46)
4

1 回答 1

1

如果您是扩展DeviceAdminReceiver,则必须为接收器添加元数据描述,例如:

<receiver 
    android:name=".AdminReceiver" 
    android:description="@string/description" 
    android:label="@string/labelValue" 
    android:permission="android.permission.BIND_DEVICE_ADMIN" 
 > 
 <meta-data  
  android:name="android.app.device_admin" 
  android:resource="@xml/lockourscreen"/> 
  <intent-filter> 
   <action android:name="android.app.action.DEVICE_ADMIN_ENABLED" /> 
  </intent-filter> 
</receiver> 

BIND_DEVICE_ADMIN正如医生所说: Must be required by device administration receiver, to ensure that only the system can interact with it.

所以<uses-permission android:name="android.permission.BIND_DEVICE_ADMIN"/>从应用程序级别删除行

于 2012-04-11T09:16:44.237 回答