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

c++ - Function signature as a function template parameter -

algorithm - What are some ways to combine a number of (potentially incompatible) sorted sub-sets of a total set into a (partial) ordering of the total set? -

How to call a javascript function after the page loads with a chrome extension? -