0

I am newbie at android , I am creating an application which I want login screen to appear on first use after installation of app , but I am not figuring out how to kill that activity , when user opens app again next time. I mean that I don't want login screen activity to appear again. I googled a lot but didn't got any useful answers. here is my code which I use in onDestroy() method.

  protected void onDestroy() {
    // TODO Auto-generated method stub
    super.onDestroy();
    android.os.Process.killProcess(MODE_PRIVATE);
 }

If I am wrong please help me out of this problem, Thanks in advance

Shabbir Dhangot
  • 8,954
  • 10
  • 58
  • 80
sap
  • 319
  • 3
  • 7
  • 21

2 Answers2

3

You're supposed to store data in the SharedPreferences (How to use SharedPreferences in Android to store, fetch and edit values) that indicate for your application that you have already provided persistent login information so that the login screen does not have to load. Although considering that is the launcher activity of the app, what you would probably need to do is start a new activity from your login activity if it's not needed, and then finish the activity.

Also, if you want to finish an Activity, then you just need to call finish().

Community
  • 1
  • 1
EpicPandaForce
  • 79,669
  • 27
  • 256
  • 428
0

You will have to save a value somewhere on your phone. On every start up, you have to check that value. If it is true, you launch the login screen and save the value as false. If it is false, you skip login screen. Another way to do it is to check if user credentials exists. If they do, you use them otherwise you show login screen.

Pphoenix
  • 1,423
  • 1
  • 15
  • 37