Is there a way to make the application always start working with Activity1 after using the "Home" button?

This application has several actions: for example: Activity1 → Activity2 → Activity3. If the application is open after the Home button is used during Activity2, the application will return to Activity2, but the desired functionality for the application always starts with Activity1 from the launch bar. Adding finish () to onStop () for Activity2 causes the application to start with Activity1 after using the Home button, but then Activity3 forces the application to return to Activity1 when it terminates, rather than Activity2, which is also undesirable. Is there a way to make the application always start with Activity1 after using the home button?

public class Activity1 extends Activity {
    ...
    public void onCreate(Bundle savedInstanceState) {
        ...
        button1.setOnClickListener(new OnClickListener() {
            public void onClick(View arg0) {
                startActivity(Activity2);
                ...

public class Activity2 extends Activity {
    ...
    private boolean applyMenuChoice(MenuItem item) {
        switch (item.getItemId()) {
        case R.id.menuItem1:
            startActivity(Activity3);
            ...
+3
1

AndroidManifest.xml. , android: clearTaskOnLaunch.

, Android.

+3

Source: https://habr.com/ru/post/1762947/


All Articles