LocalBroadcastManager を使用してブロードキャストできるサービスがあります。
Intent downloadIntent = new Intent();
downloadIntent.setAction(BroadcastActions.DOWNLOAD_APPOINTMENTS.toString());
LocalBroadcastManager.getInstance(getApplicationContext()).sendBroadcast(downloadIntent);
テストアクティビティでは、次のようにこのブロードキャストを受信しています。
IntentFilter filter = new IntentFilter();
filter.addAction(String.valueOf(BroadcastActions.DOWNLOAD_APPOINTMENTS));
filter.addAction(BluetoothDevice.ACTION_FOUND);
LocalBroadcastManager.getInstance(getActivity()).registerReceiver(receiver, filter);
同じテスト アクティビティで、ACTION_FOUND という別のアクションを追加して、Bluetooth 対応デバイスを取得しました。LocalBroadCast Manager を使用しているため、Bluetooth デバイスが見つかった場合、システムのブロードキャストを受信できませんでした。システムブロードキャストとローカルブロードキャストの両方を受信するために、これを手伝ってくれる人はいますか..?