0

Is there any event, method, flag or something else which tells me, that the next Activity has been started successfully and is shown on the screen.

MyCode to start an Activity class:

    Intent intent = new Intent(this, nextActivity.class);
    intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    startActivity(intent);

Thanks in advance

Pwnstar
  • 2,333
  • 2
  • 29
  • 52
  • (http://stackoverflow.com/questions/8515936/android-activity-life-cycle-what-are-all-these-methods-for) [Possible duplicate]. Please go through Activity Lifecycle (http://developer.android.com/training/basics/activity-lifecycle/starting.html). SO already has answers to similar questions. – Sajib Acharya Nov 20 '15 at 15:55

2 Answers2

2

onCreate() is called when the activity is created, I would strongly recommend reading up on the Activity Lifecycle if you're not sure about this.

fractalwrench
  • 4,028
  • 7
  • 33
  • 49
  • I actually do know how this basically works. The main problem is I do start an activity with a button click. But as long as the activity is not started i am able to press the button several times more, which results in multiple activity starts. So i want to disable the button as long the next activity is not started. – Pwnstar Nov 23 '15 at 08:30
0

If you can modify the started activity why not just send an broadcast once new activity's onStart() called?

or do something else you need upon activity start

Alex Wih
  • 1,015
  • 2
  • 11
  • 24
  • To fire Broadcast in new activity and inform old Activity that new one is started? Am I understood you well? – Bozic Nebojsa Nov 20 '15 at 15:56
  • @BozicNebojsa in fact it depends on what you want from your application. But in fact notifying one Activity while it in the background seems to be a bad idea because the Activity might be destroyed. – Alex Wih Nov 20 '15 at 16:02
  • you are right. It can get you into random crashes. But more important, if you are trying to do so, there is a big chance you did something bad with your app architecture. – Bozic Nebojsa Nov 21 '15 at 22:43