Reputation: 763
I have created an android app with 5 activities .i.e 1.java,2.java,3.java,4.java,5.java. and Splash also there.
I have used intents to move from one activity to another. I have defined few operations on buttons i.e changing the background image of that button and assigning values to strings in that activities.
I used moveTaskToBack()
method on clicking back button from all my java files.
and i have kept android:launchMode="singleInstance"
in manifest file.
from 5.java I have to move to Splash page and have to restart whole app ..
when i have moved from Splash to 1.java page it is showing previously entered details ..
my problem is how to clear all the previously entered details in 1.java page,2.java page,3.java page,4,java page,5.java page.
please give answer...thank uu...
Upvotes: 3
Views: 3105
Reputation: 2641
Considering you are moving from java5 class to Splash Screen.
You need to clear the previously opened activities like this;
Intent intent = new Intent(Java5Class.this, SplashScreen.class);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
startActivity(intent);
this.finish();
Upvotes: 2
Reputation: 194
after starting new activity, finish the activity you want to destroy.
StartActivity(new Intent(this,Second.class));
finish();
Upvotes: 0
Reputation: 1193
Try this
Intent intent = new Intent(getApplicationContext(), Home.class);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(intent);
finish();
This will clear all the activities on top of home.
Upvotes: 1
Reputation: 433
try like this, it will work while pressing backbutton
@Override
public boolean onKeyDown(int keyCode, KeyEvent event)
{
if ((keyCode == KeyEvent.KEYCODE_BACK))
{
Intent intent = new Intent(getApplicationContext(), previousActivvty.class);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
intent.putExtra("EXIT", true);
startActivity(intent);
finish();
}
return super.onKeyDown(keyCode, event);
}
Upvotes: 1