1

我正在尝试在我的应用程序中使用凹凸 API。我将 Bump 库项目导入到我的项目中。有谁知道为什么会这样?

04-26 21:00:15.828: W/ActivityManager(528): Permission denied: checkComponentPermission() owningUid=10072

04-26 21:00:15.828: W/BroadcastQueue(528): Permission Denial: broadcasting Intent { act=com.bump.core.util.LocationDetector.PASSIVE_LOCATION_UPDATE flg=0x10 (has extras) } from com.helloworld.utility (pid=-1, uid=10071) is not exported from uid 10072 due to receiver com.bumptech.bumpga/com.bump.core.service.PassiveLocationReceiver

这是我的 AndroidManifest.xml 的相关部分:

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />

<service android:name="com.bump.api.BumpAPI">
   <intent-filter>
      <action android:name="com.bump.api.IBumpAPI" />
   </intent-filter>
</service> 

我试图查看 Android 源代码,它来自 ActivtiyManagerService.java 中的此处:

// If the target is not exported, then nobody else can get to it.
if (!exported) {
   Slog.w(TAG, "Permission denied: checkComponentPermission() owningUid=" + owningUid);
   return PackageManager.PERMISSION_DENIED;
}

我不确定在这种情况下“目标”是什么以及需要“导出”什么。有没有其他人见过这个?

多谢你们!

4

2 回答 2

3

在服务标签中使用exported属性。例如<service android:exported="true" android:name="com.bump.api.BumpAPI">在清单中。导出的属性意味着,其他应用程序是否可以访问它(活动/服务/广播等)。在您的代码中,exported布尔值false如此条件if(!exported)始终为真,因此它从那里返回。进行我提到的更改,如果问题仍然存在,请告诉我们。

有关文档,请转到此处

于 2013-09-13T08:26:24.363 回答
2

您是否按照此处所述注册了 BroadcastReceiver ?

private final BroadcastReceiver receiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
    final String action = intent.getAction();
    try {
        if (action.equals(BumpAPIIntents.DATA_RECEIVED)) {
            Log.i("Bump Test", "Received data from: " + api.userIDForChannelID(intent.getLongExtra("channelID", 0)));
            Log.i("Bump Test", "Data: " + new String(intent.getByteArrayExtra("data")));
        } else if (action.equals(BumpAPIIntents.MATCHED)) {
            api.confirm(intent.getLongExtra("proposedChannelID", 0), true);
        } else if (action.equals(BumpAPIIntents.CHANNEL_CONFIRMED)) {
            api.send(intent.getLongExtra("channelID", 0), "Hello, world!".getBytes());
        } else if (action.equals(BumpAPIIntents.CONNECTED)) {
            api.enableBumping();
        }
    } catch (RemoteException e) {}
}
};

IntentFilter filter = new IntentFilter();
filter.addAction(BumpAPIIntents.CHANNEL_CONFIRMED);
filter.addAction(BumpAPIIntents.DATA_RECEIVED);
filter.addAction(BumpAPIIntents.NOT_MATCHED);
filter.addAction(BumpAPIIntents.MATCHED);
filter.addAction(BumpAPIIntents.CONNECTED);
registerReceiver(receiver, filter);

还要检查文档android:exported

默认值取决于活动是否包含意图过滤器。没有任何过滤器意味着该活动只能通过指定其确切的类名来调用。这意味着该活动仅供应用程序内部使用(因为其他人不知道类名)。所以在这种情况下,默认值为“false”。另一方面,存在至少一个过滤器意味着该活动是供外部使用的,因此默认值为“true”。

于 2013-09-13T08:06:13.103 回答