Dear All, Recently, I have tried to know what would happen to an alive thread, when the device goes to sleep. I program a simple activity that will create and start a thread printing "HERE AM I" repeatedly through Log.d. I expect the thread would be stopped after I "echo standby > /sys/android_power/request_state." The screen is off, but the thread still keeps alive and prints out "HERE AM I." I don't know why the thread can't be stopped. I test this through emulator (1.5cupcake) and G1(1.1?), but the results are the same. Could anyone give me some suggestions or hints about this question? Thanks in advanced.
The following is my simple activity. ===============================CODE HERE================================= ublic class TestServiceDroid extends Activity { PowerManager.WakeLock lock; Thread h; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); Thread h = new Thread(new Runnable(){ public void run(){ while(true){ try { Log.d("TEST SERVICE","HERE AM I"); Thread.currentThread().sleep(3000); } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); } } } }); h.start(); } } ===============================CODE HERE================================= Best regards, Augustin. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---