As the title says, is there a way to run BroadcastReceiver onReceive()
method asynchronously?
Based on its implementation, android runs the onReceive()
method on the main thread.
I am using the BroadcastReceiver
to explicitly request permission to communicate with a USB device. When the request permission dialog box has received permission, the onReceive()
method is called, but since it runs on the main thread, there is no way (at least, not that I know of) to signal when it is complete. Polling on a boolean flag would block the main thread, which in turn would block the onReceive()
method from being called.
Is there a way to async call the onReceive()
or is there an alternative way to explicitly (without using intent filters in the manifest) request permission and connect to a USB device?
Edit: I would like it such that the method blocks until permission is acquired and connection is established.