我为我的小部件编写了一个接收广播的自定义权限,我得到了摩托罗拉设备的权限拒绝。
创建权限
<permission
android:name="com.sample.app.WIDGET_PERMISSION"
android:description="@string/widgetDesc"
android:label="@string/widgetLabel"
android:protectionLevel="signature" >
</permission>
向清单文件添加权限
<uses-permission android:name="com.sample.app.WIDGET_PERMISSION" />
添加接收器
<receiver android:name=".MyWidget" android:label="MyApp"
android:icon="@drawable/image"
android:permission="com.sample.app.WIDGET_PERMISSION">
<intent-filter>
<action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
<category android:name="com.sample.app" />
</intent-filter>
</receiver>
我只收到摩托罗拉设备的许可拒绝消息,
07-17 11:48:18.781: W/ActivityManager(479): Permission Denial: broadcasting Intent { act=android.appwidget.action.APPWIDGET_ENABLED cmp=com.sample.app/.MyWidget} from android (pid=3116, uid=10006) requires com.sample.app.WIDGET_PERMISSION due to receiver com.sample.app/com.sample.app.MyWidget
07-17 11:48:18.781: W/ActivityManager(479): Permission Denial: broadcasting Intent { act=android.appwidget.action.APPWIDGET_UPDATE cmp=com.sample.app/.MyWidget(has extras) } from android (pid=3116, uid=10006) requires com.sample.app.WIDGET_PERMISSION due to receiver com.sample.app/com.sample.app.MyWidget
07-17 11:48:18.828: W/ActivityManager(479): Permission Denial: broadcasting Intent { act=com.motorola.blur.home.ACTION_SET_WIDGET_SIZE cmp=com.sample.app/.MyWidget(has extras) } from com.motorola.blur.home (pid=3116, uid=10006) requires com.sample.app.WIDGET_PERMISSION due to receiver com.sample.app/com.sample.app.MyWidget