0

I have 4 activities as activity1, activity2, activity3, and activity4.

I access these activities from main activity which has four buttons, each button opens a specific activity, for example button1 opens activity1 through an intent.

In these four activities I have a method which checks to see if user is logged in to firebase or not, if user is not logged the login activity opens. So here comes my problem:

When the user clicks the login button, i want him to be directed to the intended activity.

If for example he wants to open activity1, but then directed back to login activity, when he logs in he should go to activity1,

Under onclick listerner of the login button i have this intent:

Intent intent = new Intent(Login.this, activity1.class); startActivity(intent) 

This works when user actually whats to go to activity1, what if he wants to go to any other activity?

3
  • You should just need to pass a parameter: stackoverflow.com/questions/2405120/… Then check that parameter when the login is successful Commented May 29, 2021 at 20:24
  • Your question is actually not clear enough. Do you want to go to another activity2, not activity1...then change it to activity2 not activity1 but if this has to happen on a condition, then implement the codition and put the navigation code inside. Commented May 29, 2021 at 20:45
  • You could leave a trail in the Intent and use a property to indicate the destination to be used in the login activity. See extras in Intent. Commented May 29, 2021 at 23:38

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.