好吧,我正在关注此链接
甚至添加了广播接收器,如上面的链接所示。但我没有通知任务完成,我想在这个 Intent 服务完成后运行一些活动。任何人都可以帮助我。
我收到如下错误:
Permission Denial: broadcasting Intent
{ act=com.saaranga.services.GetTaxonomy.DATA_RETRIEVED
cat=[android.intent.category.DEFAULT] (has extras) }
from com.saaranga.lib (pid=1089, uid=10034)
equires com.saaranga.services.Permissions.SEND_SIMPLE_NOTIFICATIONS
due to receiver com.saaranga.lib/com.saaranga.services.ServiceReciver
在 intentService 我已经初始化:
public static final String ACTION_NOTIFY="com.saaranga.services.GetTaxonomy.DATA_RETRIEVED";
private void sendSimpleBroadcast(int count)
{
Intent broadcastIntent = new Intent();
broadcastIntent.setAction(GetTaxonomy.ACTION_NOTIFY);
broadcastIntent.addCategory(Intent.CATEGORY_DEFAULT);
broadcastIntent.putExtra(PARAM_OUT_COUNT, count);
// broadcastIntent.setClass(getApplicationContext(), getClass());
sendBroadcast(broadcastIntent, Permissions.SEND_SIMPLE_NOTIFICATIONS);
}
并创建了一个权限类:
package com.saaranga.services;
public class Permissions {
public static final String SEND_SIMPLE_NOTIFICATIONS = "com.saaranga.services.Permissions.SEND_SIMPLE_NOTIFICATIONS";}
在清单文件中:
<permission
android:name="com.saaranga.services.Permissions.SEND_SIMPLE_NOTIFICATIONS"
android:label="permission to send simple notifications"
android:permissionGroup="android.permission-group.PERSONAL_INFO"
android:protectionLevel="normal" />
<service
android:name="com.saaranga.services.GetTaxonomy"
android:enabled="true"
android:exported="true">
</service>
<receiver android:name="com.saaranga.services.ServiceReciver"
android:exported="true"
android:permission="com.saaranga.services.Permissions.SEND_SIMPLE_NOTIFICATIONS">
<intent-filter>
<action android:name="com.saaranga.services.GetTaxonomy.DATA_RETRIEVED"/>
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</receiver>
甚至在上面的链接中添加了广播接收器。但我没有通知任务完成,我想在这个 Intent 服务完成后运行一些活动。任何人都可以帮助我。