One user at a time while running an app.

Arjun Mr

New member
May 9, 2016
1
0
0
Visit site
I am trying to develop an application in which a login is added. But i am stuck with the following problem:

1. How can i detect whether a user has exit from the application(once accessed) without loggedout.(say if he exit the app without clicking the logout button)

2. If it is not possible, the user can access the application from any android phones with the same user name and password. But that shouldn't be allowed in my application.

3. Please provide any suggestions for the same.
 

acommoner

New member
May 5, 2016
2
0
0
Visit site
1. When a user exits an application, your Application, Activity, and Fragment classes will go through their general lifecycle calls (Activity | Android Developers), so if you want to do anything at these moments, just implement those methods.

As for keeping a user logged in, you'll need to store the user's credentials somewhere after they have logged in, and then when the app starts up again, grab the credentials and use them again if they've already been entered. See this stack overflow post for a discussion: google app engine - Best place for storing user login credentials in Android - Stack Overflow

2. If you're looking at cross-device login, you'll need to store login information on a server or online db somewhere, and then verify it when the user goes to log in. To make it simpler, you can also use login with Facebook/Google+/Amazon Cognito to make it simpler & not have to do everything yourself.