L
L
Lord Drous2015-06-12 22:07:12
Java
Lord Drous, 2015-06-12 22:07:12

How to save the user after authorization?

there is an activity (1), where a person logs in and comes to another activity (2), when you press back on 2, he goes to 1, that is, he does not save, does not understand that the person has entered, how to save and do so that when you press back on the phone transferred to another asset, saving all this

Answer the question

In order to leave comments, you need to log in

2 answer(s)
K
KaktusTeam, 2015-06-12
@LorDDrouS

Good afternoon,
The simplest thing you can do in order not to fall into the activity login is to finish the activity login at the start of activity 2, like this:

class LoginActivity extends Activity {
   ...
   private void startActivity2() {
      Intent intent = new Intent(this, Activity2.class);
      startActivity(intent);
      finish();
   }
   ...
}

When the finish() method is called, the login activity will disappear from the stack, and when you click back from activity 2, there will be no transition to it.
Good luck!

K
Konstantin Berkov, 2015-06-12
@konstantin_berkow

Use AccountManager, save the user's refresh token and other information necessary for re-authorization in it, and from the authorization activity, if there is an authorized user and a valid token, throw it on the desired activity.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question