android - Using Intents to navigate between activities -


i navigate between activities using intents

pictorial representation looks below::

enter image description here

in activity - .......... there next button go activity b

photos.setonclicklistener(new onclicklistener() {              public void onclick(view v) {                 // todo auto-generated method stub                  intent photointent=new intent(a.this,b.class);                 startactivity(photointent);              }         }); 

in activity - b .......... there next button go again activity c

map.setonclicklistener(new onclicklistener() {                  public void onclick(view v) {                     // todo auto-generated method stub                      intent photointent=new intent(b.this,c.class);                     startactivity(photointent);                  }             }); 
  • now in activity c .... there 1 button
  • if use above code can't go 2 activities depending on navigation came from

suppose came a c ------ when use back button in c go a

again when came b c ----- when use back button in c go b

there 1 back button in activity c


[edit]

its came activity activity c ----- when use button in activity c should go activity a

&

for same scenario if came activity b activity c - - - - when use button in activity c should go activity b

------- i trying relate switching case kind of mechanism button in activityc


how achieve

hope clear

there 1 button in activity c 

if understand correctly, activity c can started both activity a , activity b. if case, button in activity c should have following code:

backbutton.setonclicklistener(new onclicklistener() {      @override     public void onclick(view v) {          // takes whichever activity launched c         finish();     } }); 

when launch activity c activity a, stack .... {activity a}, {activity c}. calling activity#finish() in activity c take activity a. same scenario unfolds when activity c started activity b.

note if call finish() in activity after launching activity c, button take activity positioned before activity in stack.


Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -