Reputation: 3682
i have an Activity which is singleTask, and i want to relaunch (reshow) this Activity when user clicks in a button.
When i first call the activity it will play a music based in some data passed via Intent. But when the user press back to my MainActivity he will be able to press a button to bring he back to the Player activity. The problem is that when the user presses the button, the activity is relaunched, but it not seems to be via onNewIntent
because it starts to play again from the beggining (sends the original playlist to service starting from beggining).
Is there to just reshow the activity without "doing nothing", just continuing what was doing previously?
EDIT:
Thats how im calling my singleTask Activity:
littlePlayer.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (!isPlaying) {
Intent it = new Intent(MainActivity.this, Player_.class);
it.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT | Intent.FLAG_ACTIVITY_NEW_TASK);
it.putExtra("json", lastJson);
it.putExtra("position", position);
it.putExtra("playing_position", playingPosition);
startActivity(it);
}else{
Intent it = new Intent(MainActivity.this, Player_.class);
it.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT | Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(it);
//Player_.intent(MainActivity.this).start();
}
}
});
Upvotes: 0
Views: 282
Reputation: 1127
Change your activity as singleTop
from singleTask
to avoid relaunching the activity.
Then, call your activity like this,
Intent intent= new Intent(context, YourActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_SINGLE_TOP);
Upvotes: 1