java - Starting a method if activity is started from another activity -


hi!

i'm ask dumb question, assure i've searched web , either there no answer (highly unlikely) or i've come across solution have been unable recognize it.

anyway, here is: let's have 2 activities, , b. activity b applications launcher activity, when start app, activity b first run. there, i'm going start activity via intent. now, i'm in activity , starting activity b again via intent. now, having started activity b via intent activity a, want run method showstuff() that's inside activity b. how?

sorry weird story, i'm unfortunately unable express myself in techincal language. thank help!

pass boolean flag "showstuff" though intent when start b

intent intent = new intent(this, b.class); intent.putextra("showstuff", true); startactivity(intent);   

and in b in oncreate

intent intent = getintent(); if (intent != null) {     boolean showstuff = intent.getbooleanextra("showstuff", false);     if (showstuff) {          showstuff();      } }   

also in b override onnewintent

@override protected void onnewintent(intent intent) {     super.onnewintent(intent);      if (intent != null) {         boolean showstuff = intent.getbooleanextra("showstuff", false);         if (showstuff) {              showstuff();          }     }   } 

Comments

Popular posts from this blog

Perl - how to grep a block of text from a file -

delphi - How to remove all the grips on a coolbar if I have several coolbands? -

javascript - Animating array of divs; only the final element is modified -