I read from the developer guide:
A BroadcastReceiver object is only valid for the duration of the call to onReceive(Context, Intent). Once your code returns from this function, the system considers the object to be finished and no longer active.
This has important repercussions to what you can do in an onReceive(Context, Intent) implementation: anything that requires asynchronous operation is not available, because you will need to return from the function to handle the asynchronous operation, but at that point the BroadcastReceiver is no longer active and thus the system is free to kill its process before the asynchronous operation completes.
From by BroadcastReceiver
I manage to catch the intent I am interessed in, and in response I want my app to take a picture: but in the above-written explanation, I read that
anything that requires asynchronous operation is not available
and I may even succeed in taking a picture, but maybe onReceive
has already returned. My question is: what is the best practice to take a picture from a BroadcastReceiver
?
0 comments:
Post a Comment