Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Not to destroy current activity on back button is pressed

I have two activities, A and B. I have a button in A,when pressed starts a new intent to B. However whenever I press the back button while in B, than click the button again is restarts Activity.I do not want to do that,I want it to resume Activity B. Actually I am doing some networking in Activity B and I want to save unless the user wants to refresh. How can I do it? Thanks in advance

like image 267
Dory Avatar asked Dec 19 '12 09:12

Dory


1 Answers

Use

@Override
    public void onBackPressed(){
        moveTaskToBack(true);
    }

Hope, It must help you

like image 144
No_Rulz Avatar answered Oct 05 '22 14:10

No_Rulz