How can you distinguish onPause() due to onNewIntent vs user action in android -


if have set activity in android fire onnewintent() when receives intents when in stopped or paused state. goes through following sequence if receives intent while running:

onpause() -> onnewintent() -> onresume()

but if paused due user action onpause().

now if want in case user hid app not in case getting new background intent. doing example cancelling recording when app gets hidden, seems screwed.

you wont know until sometime in future whether got onpause because user hid app or because of incoming background intent.

am missing or broken?

why don't send onnewintent callback if intent while running. rather pause, onnewintent, resume sequence?

if stumbles upon again - not possible detect if onpause() called due new intent onresume() can detected. add bundle_key_new_intent_called when onnewintent() called , check flag in onresume() , take required action.

  @override     protected void onnewintent(intent intent) {         super.onnewintent(intent);         intent.putextra(bundle_key_new_intent_called, true);         setintent(intent);     }      @override     protected void onresume() {         super.onresume();         intent intent = getintent();         boolean isresumedduetonewintent = (intent != null && intent.getbooleanextra(bundle_key_new_intent_called, false));         if (isresumedduetonewintent) {             actonnewintent();         }     } 

Comments

Popular posts from this blog

google api - Incomplete response from Gmail API threads.list -

Installing Android SQLite Asset Helper -

Qt Creator - Searching files with Locator including folder -