I have two activities (LoginActivity and MainActivity) with the LoginActivity being the MAIN and LAUNCHER in the android manifest file. Once the App launches, I don't want to go back to the LoginActivity even when Back button is pressed. How can I ensure the MainActivity becomes the main/ home activity though its not in the manifest as the MAIN during run time.
Just call finish()
method of the Activity
class on successfull log in.You will never see that Activity
again in your application (obviously you must have to apply logic's to make it appear again, when some user logs out)
Do it like this When user is authenticated by correct username-password combination
Intent i=new Intent(LogInActivity.this,HomeActivity.class);
startActivity(i);
finish();
Then the previous activity (LogInActivity
) will be finished.