ActivityForwarding

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

ActivityForwarding

Postby sommeralex » Sun Jan 27, 2008 1:58 am

hello.. :cry:

i dont know why, but i want to forward to one activity from another like in the Forward Example - in this case, i want to restart my app.

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.  
  2. Intent intent = new Intent();
  3. intent.setClass(AirMain.this, AirMain.class);
  4. startActivity(intent);
  5. finish();
  6.  
  7.  
Parsed in 0.031 seconds, using GeSHi 1.0.8.4


the forwarding works - but - i still can go "back" to my previous activity. Even if i forward 2x like:

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. intent.setClass(AirMain.this, Forward.class);
  2. startActivity(intent);
  3. finish();
  4.  
Parsed in 0.030 seconds, using GeSHi 1.0.8.4


and in the forward class i do the same back:

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. intent.setClass(Forward.this, AirMain.class);
  2. startActivity(intent);
  3. finish();
  4.  
Parsed in 0.033 seconds, using GeSHi 1.0.8.4


but still, i can press the back button from the forwarded class.. ?
sommeralex
Experienced Developer
Experienced Developer
 
Posts: 95
Joined: Sun Jan 20, 2008 3:12 am
Location: Vienna

Top

Postby res » Sun Jan 27, 2008 6:23 am

The previous Activity is stored in the history stack so pressing the back button will return you to the previous Activity running. If you don't want the back button to work you need to remove the all the previous Activities from the history stack.

Taken from http://code.google.com/android/kb/commontasks.html
"An activity can remove itself from the history stack by calling Activity.finish() on itself, or the activity that opened the screen can call Activity.finishSubActivity() on any screens that it opens to close them."
res
Senior Developer
Senior Developer
 
Posts: 146
Joined: Tue Nov 20, 2007 8:14 pm
Location: United States

Postby sommeralex » Sun Jan 27, 2008 11:26 am

intent.setClass(AirMain.this, Forward.class);
startActivity(intent);
finish();

i am finishing it!
sommeralex
Experienced Developer
Experienced Developer
 
Posts: 95
Joined: Sun Jan 20, 2008 3:12 am
Location: Vienna

Postby res » Sun Jan 27, 2008 7:47 pm

sommeralex wrote:intent.setClass(AirMain.this, Forward.class);
startActivity(intent);
finish();

i am finishing it!


Sorry didn't read all the code you posted. Have you tried this.finish() or AirMain.finish() ?
res
Senior Developer
Senior Developer
 
Posts: 146
Joined: Tue Nov 20, 2007 8:14 pm
Location: United States

Postby sommeralex » Tue Jan 29, 2008 6:30 pm

yes, i tried it.. now, i just overwrite the onKeyPress method..
Last edited by sommeralex on Tue Jan 29, 2008 10:03 pm, edited 1 time in total.
sommeralex
Experienced Developer
Experienced Developer
 
Posts: 95
Joined: Sun Jan 20, 2008 3:12 am
Location: Vienna

Postby res » Tue Jan 29, 2008 8:37 pm

sommeralex wrote:yes, i tried it.. now, i just override the onKeyPress method..


so did you get it working?
res
Senior Developer
Senior Developer
 
Posts: 146
Joined: Tue Nov 20, 2007 8:14 pm
Location: United States

Top

Postby sommeralex » Tue Jan 29, 2008 8:42 pm

only with overwriting..
sommeralex
Experienced Developer
Experienced Developer
 
Posts: 95
Joined: Sun Jan 20, 2008 3:12 am
Location: Vienna

Top

Return to Other Coding-Problems

Who is online

Users browsing this forum: MSNbot Media and 20 guests