How to define started activity when relaunching Android application?

后端 未结 1 484
一整个雨季
一整个雨季 2020-12-21 10:51

I am fairly new to Android, and am currently working on a simple XMPP Client. A user should be able to log in, and should be notified whenever an XMPP message arrives. It sh

相关标签:
1条回答
  • 2020-12-21 11:15

    What you can do, as I understand you issue, is use ShaeredPreferences. Create a preference like "loggedin" and set a boolean variable to true the first time they log in. Now you can set this to false when they click the "logout" Button.

    When the Activity is started you can check the SharedPreference before calling setContentView() and if the value is true then finish() the LoginActivity and open your other Activity.

    The link to the docs I provided has a good example of creating, opening, and editing SharedPreferences

    0 讨论(0)
提交回复
热议问题