Android : Android and sendOrderedBroadcast - how to immediately get the results?

on Monday, September 1, 2014


In some cases I need to get data from misc intents and try to use sendOrderedBroadcast. But this call is async, and I don't know how to wait for it. I try:



onCreate(...)
{
// ...
sendOrderedBroadcast(...);
if (someResult!=null)
{
// Never executed
}
// ...
}

onButtonPressed(...)
{
if (someResult!=null)
{
// Often fires
}
}


I think I need to call something like Windows message loop



while (::PeekMessage(...))
{
GetMessage(...);
}


after sendOrderedBroadcast and before using someResult.


How I can do it? Or, is there more convenient and right way?


0 comments:

Post a Comment