如何接收标记的意图 FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT
How to receive intents flagged FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT
在 Android 5.0 之后,HidService.java 包括以下功能:
private void broadcastReport(BluetoothDevice device, byte[] report, int rpt_size) {
Intent intent = new Intent(BluetoothInputDevice.ACTION_REPORT);
intent.putExtra(BluetoothDevice.EXTRA_DEVICE, device);
intent.putExtra(BluetoothInputDevice.EXTRA_REPORT, report);
intent.putExtra(BluetoothInputDevice.EXTRA_REPORT_BUFFER_SIZE, rpt_size);
intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT);
sendBroadcast(intent, BLUETOOTH_PERM);
}
我在 Intent 中找不到关于此标志的任何文档。我应该如何在我的应用程序中接收此广播意图?
==============
编辑的内容删除并形成新问题here
此常量未记录在 Intent API docs 中,因为它不适合 public 使用。
这是我从 the android source code 中找到的描述。 (第 3018 行)
FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT
public static final int FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT
If set, when sending a broadcast before boot has completed only registered receivers will be called -- no BroadcastReceiver components will be launched. Sticky intent state will be recorded properly even if no receivers wind up being called. If FLAG_RECEIVER_REGISTERED_ONLY is specified in the broadcast intent, this flag is unnecessary.
This flag is only for use by system sevices as a convenience to avoid having to implement a more complex mechanism around detection of boot completion.
强调我的。
在 Android 5.0 之后,HidService.java 包括以下功能:
private void broadcastReport(BluetoothDevice device, byte[] report, int rpt_size) {
Intent intent = new Intent(BluetoothInputDevice.ACTION_REPORT);
intent.putExtra(BluetoothDevice.EXTRA_DEVICE, device);
intent.putExtra(BluetoothInputDevice.EXTRA_REPORT, report);
intent.putExtra(BluetoothInputDevice.EXTRA_REPORT_BUFFER_SIZE, rpt_size);
intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT);
sendBroadcast(intent, BLUETOOTH_PERM);
}
我在 Intent 中找不到关于此标志的任何文档。我应该如何在我的应用程序中接收此广播意图?
==============
编辑的内容删除并形成新问题here
此常量未记录在 Intent API docs 中,因为它不适合 public 使用。
这是我从 the android source code 中找到的描述。 (第 3018 行)
FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT
public static final int FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT
If set, when sending a broadcast before boot has completed only registered receivers will be called -- no BroadcastReceiver components will be launched. Sticky intent state will be recorded properly even if no receivers wind up being called. If FLAG_RECEIVER_REGISTERED_ONLY is specified in the broadcast intent, this flag is unnecessary.
This flag is only for use by system sevices as a convenience to avoid having to implement a more complex mechanism around detection of boot completion.
强调我的。