Starting activity with no "stack"

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

Starting activity with no "stack"

Postby phix » Thu Jun 03, 2010 12:03 am

Not sure if that's the right term, but I'd like to start an activity from a service when shake is detected. It works, but when the new activity is started, I can hit the back button and it takes me to the last screen I was on when the app was last launched. Here's the runnable that starts it:
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. private Runnable listenForShake = new Runnable(){
  2.         public void run(){
  3.                 Log.i(TAG, "Runnable executed.");
  4.                 shakeList.setOnShakeListener(new ShakeListener.OnShakeListener(){
  5.                         public void onShake(){
  6.                                 vibe.vibrate(new long[]{0, 100, 100, 50}, -1);
  7.                                 Intent light = new Intent(getApplicationContext(), LightScreen.class);
  8.                                 light.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  9.                                 startActivity(light);
  10.                         }
  11.                 });
  12.         }
  13. };
  14.  
Parsed in 0.031 seconds, using GeSHi 1.0.8.4


I tried a few other Intent flags but they didn't seem to help. How would I go about starting this activity, and when the user hits the "back" button, it returns to the home screen, or whereever they happened to be before this was called?
Posting questions without code is like going to the doctor and saying "it hurts, fix it."
phix
Master Developer
Master Developer
 
Posts: 230
Joined: Mon Mar 15, 2010 10:37 am

Top

Re: Starting activity with no "stack"

Postby phix » Thu Jun 03, 2010 1:37 am

Thanks anarche.. those look promising.
Posting questions without code is like going to the doctor and saying "it hurts, fix it."
phix
Master Developer
Master Developer
 
Posts: 230
Joined: Mon Mar 15, 2010 10:37 am

Top

Return to Other Coding-Problems

Who is online

Users browsing this forum: Yahoo [Bot] and 19 guests