How Android onActivityForResult reacts toggling app between foregrnd AND bckgrnd?

If you remove the call to finish() in onPause, then hitting the home key calls only the child activities onPause method. When you re-launch the app, only the child activities onResume method is called. None of the parent methods seem to be called.

The pattern of calling setResult in the activity and then finish in onPause FAILS after the user changes the phone orientation. So if the user enters data, saves the data (calling setResult in onSaveButtonClicked), changes phone orientation, and exits calling finish and the changes ARE NOT SAVED Consider calling finish() immediately after setResult at the moment you have enough data to set the result, exiting the child activity UPDATE BUTTON HANDLER final Button buttonUpdate= (Button)findViewById(R.id. ButtonPasswordUpdate); buttonUpdate.

SetOnClickListener(new View.OnClickListener() { public void onClick(View v) { String password= editTextPasswordFirst.getText().toString(); String verify= editTextPasswordSecond.getText().toString(); String err=""; if (password. Equals(verify) && (password.length() >= minimumPasswordLength)) { // 1) SUCCESS ResetTimeoutValues(timeoutType); // new password so calculate new timeout time isValidKey= true; PasswordState outPasswordState= new PasswordState(lengthKey, timeExpire, isValidKey, timeoutType, password, isHashPassword, minimumPasswordLength); Bundle b= new Bundle(); b. PutSerializable("jalcomputing.confusetext.

PasswordState", outPasswordState); getIntent(). PutExtras(b); setResult(RESULT_OK,getIntent()); // call home with data on success only finish(); // go back.

If you remove the call to finish() in onPause, then hitting the home key calls only the child activities onPause method. When you re-launch the app, only the child activities onResume method is called. None of the parent methods seem to be called.

The pattern of calling setResult in the activity and then finish in onPause FAILS after the user changes the phone orientation. So if the user enters data, saves the data (calling setResult in onSaveButtonClicked), changes phone orientation, and exits calling finish and the changes ARE NOT SAVED. Consider calling finish() immediately after setResult at the moment you have enough data to set the result, exiting the child activity.

// UPDATE BUTTON HANDLER final Button buttonUpdate= (Button)findViewById(R.id. ButtonPasswordUpdate); buttonUpdate. SetOnClickListener(new View.OnClickListener() { public void onClick(View v) { String password= editTextPasswordFirst.getText().toString(); String verify= editTextPasswordSecond.getText().toString(); String err=""; if (password.

Equals(verify) && (password.length() >= minimumPasswordLength)) { // 1) SUCCESS ResetTimeoutValues(timeoutType); // new password so calculate new timeout time isValidKey= true; PasswordState outPasswordState= new PasswordState(lengthKey, timeExpire, isValidKey, timeoutType, password, isHashPassword, minimumPasswordLength); Bundle b= new Bundle(); b. PutSerializable("jalcomputing.confusetext. PasswordState", outPasswordState); getIntent().

PutExtras(b); setResult(RESULT_OK,getIntent()); // call home with data on success only finish(); // go back.

Thanks for the explanation. As per my req I don't need to return or save any data back to the Parent activity. The purpose is When user is in child activity .. app is brought to bckgrnd.... the next time the app is brought back to foregrnd I don't want my child activity to show up... I want see my parent activity.

This is the req. Is there any better way to do this flow other using startActivityForResult? – AKh Mar 23 at 17:12 @Akh Without knowing your exact requirements I can only guess.

Why not launch the child activity in onCreate, say only after a hard kill, and call finish in ChildActivity. OnPause? This would meet the requirements for say a splash screen that goes away when the user hits the Home key, but returns if the user hits the back key twice.

– JAL Mar 23 at 18:58 hi Jal, Sorry I didn't get your point clearly. If you don't mind can you elaborate on this please. – AKh Mar 23 at 19:29 @Akh If you do not need to return data from child Activity to Parent Activity you can just call startActivity in the Parent Activity button.

OnClick and call finish in ChildActivity.onPause. IF you do this, what requirement is not met? – JAL Mar 23 at 19:47 Works like charm.

Thank you. Jal a different question. If an app is brought to the background waht happens to the UI Thread which was running this app?

Will sleep or killed? When app back to foreground will the same thread be notified or a new thread will created and associated with the app instance? – AKh Mar 23 at 21:54.

When you re-launch the app, only the child activities onResume method is called. None of the parent methods seem to be called. The pattern of calling setResult in the activity and then finish in onPause FAILS after the user changes the phone orientation.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions