java - Define source of a click? -


is possible define source of click? can access mainactivity through either clicking on recyclerview or through notification action. depending on is, need provide different info. there way of saying: if click recyclerview then..., else if notification action then...?

what can think of far this, problem not using buttons such:

button mclickbutton1 = (button)findviewbyid(r.id.clickbutton1); mclickbutton1.setonclicklistener(this); button mclickbutton2 = (button)findviewbyid(r.id.clickbutton2); mclickbutton2.setonclicklistener(this);  public void onclick(view v) {     switch (v.getid()) {         case  r.id.clickbutton1: {             // button 1 click             break;         }          case r.id.clickbutton2: {             // button 2 click             break;         }     } } 

thanks!

you have define 2 different calling intents same activity , put info each view example :

  mclickbutton1.setonclicklistener(new onclicklistener(){    public void onclick(view v) {      intent view1_int = new intent (this, mainactivity.class);       view1_int.putextra("calling intent" ,"recyclerview");       startaactivityforresult(view1_int);   } }); mclickbutton2.setonclicklistener(new onclicklistener(){    public void onclick(view v) {      intent view2_int = new intent (this, mainactivity.class);       view1_int.putextra("calling intent" ,"notification action");       startaactivityforresult(view1_int);   } }); 

and in oncreate method in mainactivity can :

 string callin_view;  callin_view =getresources.getintent.getextras("calling_intent"); 

this retrieve name of calling source defined


Comments

Popular posts from this blog

Command prompt result in label. Python 2.7 -

javascript - How do I use URL parameters to change link href on page? -

amazon web services - AWS Route53 Trying To Get Site To Resolve To www -