[Solved] Backward Activity-Navigation using BackKey

Put your problem here if it does not fit any of the other categories.

[Solved] Backward Activity-Navigation using BackKey

Postby balajimani » Wed Feb 06, 2008 10:24 am

Hi,

I am new to android. I done an application with four to five screen navication. When i come back from one screen to previos screen. It come out the application. What should i need to do when i press back button in the emulator it should come one by one.

I am urgently in need of this. Can any one can help.

Thanks and Rgards,
Bala.
balajimani
Freshman
Freshman
 
Posts: 4
Joined: Wed Jan 23, 2008 7:44 am
Location: Bangalore

Top

Postby plusminus » Wed Feb 06, 2008 6:14 pm

Hello balajimani,

how did you advance from one Activity to another :?:
With startActivity() or startSubActivity() :?: Did you use finish() with the 'old' Activities :?:

With me startSubActivity() and no finish() after that works well.

Regards,
plusminus
Image
Image | Android Development Community / Tutorials
User avatar
plusminus
Site Admin
Site Admin
 
Posts: 2688
Joined: Wed Nov 14, 2007 8:37 pm
Location: Schriesheim, Germany

Postby balajimani » Fri Feb 08, 2008 1:01 pm

hi,

Thanks for your reply..

can i have some example for that..

Thanks and Regards,
Balaji.
balajimani
Freshman
Freshman
 
Posts: 4
Joined: Wed Jan 23, 2008 7:44 am
Location: Bangalore

Postby Jesmiatka » Fri Feb 08, 2008 1:09 pm

var defined before the oncreate used for creating subActivity
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.  
  2. private static final int ACTIVITY_CREATE = 0;
  3.  
  4.  
Parsed in 0.029 seconds, using GeSHi 1.0.8.4


Going to another screen with subactivity:
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.  
  2. Intent intent = new Intent(page.this, page2.class);
  3.  
  4. startSubActivity(intent, ACTIVITY_CREATE);
  5.  
  6.  
Parsed in 0.031 seconds, using GeSHi 1.0.8.4


If you use this method every time you open a new screen you will be able to use the back button.
If you have the finish() command somewhere in your code, then you won't be able to return to this screen since you said you are done with that one.

[edit]
fixed some grammar
[/edit]
Last edited by Jesmiatka on Fri Feb 08, 2008 2:46 pm, edited 1 time in total.
Jesmiatka
Senior Developer
Senior Developer
 
Posts: 164
Joined: Mon Feb 04, 2008 3:37 pm
Location: Netherlands

Postby plusminus » Fri Feb 08, 2008 2:44 pm

Exactly :)
Image
Image | Android Development Community / Tutorials
User avatar
plusminus
Site Admin
Site Admin
 
Posts: 2688
Joined: Wed Nov 14, 2007 8:37 pm
Location: Schriesheim, Germany

Back Key navigation

Postby balajimani » Tue Feb 12, 2008 3:25 pm

hi

Thanks for your reply.

In that I am not going for another java class. I am having different XML file. I navigating in the same java file using different XML files.

In this how i need to use the above mentioned method.

Thanks and Regards,
Balaji.
balajimani
Freshman
Freshman
 
Posts: 4
Joined: Wed Jan 23, 2008 7:44 am
Location: Bangalore

Top

Postby Jesmiatka » Tue Feb 12, 2008 3:30 pm

Hi,

I do not think you can use the Back button if you change your ContentView all the time. (I am supposing you do that since you change the XML all the time)
Plusminus might know more, but I am pretty sure you can't navigate back.
Jesmiatka
Senior Developer
Senior Developer
 
Posts: 164
Joined: Mon Feb 04, 2008 3:37 pm
Location: Netherlands

Postby plusminus » Tue Feb 12, 2008 3:37 pm

Hello guys,

perhaps it is possible to intercept the BACK-Key.
There is at least a Keycode: KeyEvent.KEYCODE_BACK what means that it is probably doable in a way.

Regards,
plusminus
Image
Image | Android Development Community / Tutorials
User avatar
plusminus
Site Admin
Site Admin
 
Posts: 2688
Joined: Wed Nov 14, 2007 8:37 pm
Location: Schriesheim, Germany

Top

Return to Other Coding-Problems

Who is online

Users browsing this forum: No registered users and 11 guests