user1302569
user1302569

Reputation: 7191

Run Activity from beginning

I have application which when start I run MainActivity and after get some data I choose which next activity should be started. I have a problem with something like that: when I start first time MainActivity start and choose correct activity. When I am in correct activity and use home button and choose again application from menu Application start not from MainActivity but from my correct activity. How can I start my application always from MainActivity even if I use home button to hide application to background and chose from menu button again my app?

Upvotes: 0

Views: 50

Answers (1)

ObAt
ObAt

Reputation: 2387

You can simply override onResume() in your other Activity and finish your current Activity and start MainActivity

    @Override
    public void onResume() {
        super.onResume();


        Intent startAct= new Intent(OtherActivity.this,
                            MainActivity.class);
                    startActivity(startAct);
        finish();
    }

Upvotes: 1

Related Questions