I want to stop an activity from finishing . I know I have to override onBackPressed and remover super.onBackpressed. and do my coding. know i want to know what should i write in onBackpressed to not to delete it but put it in background.I found a solution below.
@Override
public void onBackPressed() {
moveTaskToBack(true);
return;
}
but it will close the application and act like a home button. But i want to go to the previous Activity where i came from. And one major thing i need is .. I have a button to open this particular activity from any where it should be still where i left of..because it is an AudiopLAYER WITH a seekbar..from where ever i call it .. it should show its current progress. I mean i need a way to hide an activity on Background. and from any Activity i call it . it should call from the stack. i don't want to open a new instance of it.. Through googling i got an idea but don't know how to implement it..
@Override public void onBackPressed() {
//super.onBackPressed();
Intent backIntent = new Intent(this, SongsList.class);
backIntent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
startActivity(backIntent);
}
A question related to this is here.
I wanted to do this but from any other activity it should be shown..
I find a solution to backPressed but how could i change it to my needs..
@Override
public void onBackPressed() {
Log.d("CDA", "onBackPressed Called");
Intent setIntent = new Intent(Intent.ACTION_MAIN);
setIntent.addCategory(Intent.CATEGORY_HOME);
setIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(setIntent);
}