Skip to content Skip to sidebar Skip to footer

How To Define Started Activity When Relaunching Android Application?

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 should be

Solution 1:

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

Post a Comment for "How To Define Started Activity When Relaunching Android Application?"