Reputation: 4464
my Main launcher activity (the one that has android.intent.action.MAIN
as its action) is Login page.
After successful login I started HOME activity and finish()
the LOGIN one to prevent users returning to that page by pressing BACK button.
When I press SIGN OUT button, I want the app to return to Login page. But I can't find a way to do it. Here's the sign out code:
//This method is in HOME activity
private void signOut(){
Intent i = new Intent("android.intent.action.MAIN");
startActivity(i);
finish();
}
That code will open dialog box listing all applications in my phone for me to choose. I tried putting the package name + class name (com.example.test.Login
) as the Intent but keep getting this error:
android.content.ActivityNotFoundException: No Activity found to handle Intent
I know I can trick this problem by using Splash screen as Main activity. But If there is another better solution, I want to know it.
Thanks
Upvotes: 1
Views: 1431
Reputation: 28823
Use
Intent i = new Intent(this, LoginPage.class);
startActivity (i);
finish();
Upvotes: 3