E
E
Eugene2017-01-02 22:06:20
Android
Eugene, 2017-01-02 22:06:20

Transitions between activities?

df6cde721c91445e8b334d318bff63b9.png
Activity ONE, when I click on the buttons on it, I get into the THREE or FOUR activity, the same goes for the TWO activity. How to programmatically read from which activity I got into activity three or four, and when I press the back button (3), go to the activity from which I got here? starts instantly.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vitaly Stolyarov, 2017-01-02
@UDZHEN

To identify (where it came from), you need to use Intent
When calling an activity, place data

Intent intent = new Intent(this, THREE.class);
intent.putExtra("activity","first");
startActivity(intent);

and in THREE and get
Intent intent = getIntent();
String activity = intent.getStringExtra("activity");

Source
for back button: stackoverflow.com/questions/6927628/android-starta...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question