I tried to call removeCallbacks in onPause, like this: removeCallbacks(r1); but it doesn't good.
Here is my code: public class Screen extends Activity{ int counter = 0; Intent result; Runnable r1; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.screen); SharedPreferences content = getSharedPreferences("counter", 0); SharedPreferences.Editor editor = content.edit(); editor.putInt("counter", 0); editor.commit(); result = new Intent("com.problem.RESULT"); r1 = new Runnable() { @Override public void run() { startActivity(result); } }; ready.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub ready.setVisibility(-1); click.setVisibility(1); counter = 0; ready.postDelayed(r1, 60000); } }); @Override protected void onPause() { // TODO Auto-generated method stub super.onPause(); SharedPreferences content = getSharedPreferences("counter", 0); SharedPreferences.Editor editor = content.edit(); editor.putInt("counter", counter); editor.commit(); //////////// removeCallbacks(r1); //////////// } I declared the buttons, and everything, I only have problem with the removeCallbacks. Thanks. On okt. 9, 13:52, Mark Murphy <mmur...@commonsware.com> wrote: > On Sun, Oct 9, 2011 at 7:26 AM, Zwiebel <hunzwie...@gmail.com> wrote: > > Ok thanks I could make it now with it, I had a problem in my code. Now > > I have an another problem: Even if the user exit the program in THE > > minute, my Activity will appear itself. How can I do against it? > > Call removeCallbacks() to remove the scheduled Runnable. > > -- > Mark Murphy (a Commons > Guy)http://commonsware.com|http://github.com/commonsguyhttp://commonsware.com/blog|http://twitter.com/commonsguy > > Android 3.1 Programming Books:http://commonsware.com/books -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en