카테고리 없음
백그라운드 문제
Yi Junho
2010. 12. 27. 17:47
반응형
package com.pyo.android.simple.service; , , , , public class SimpleServiceIntent extends android.app.Service { private int increment = 0 ; private static final String DEBUG = SimpleServiceIntent.class.getSimpleName(); @Override public void onCreate() { super.onCreate(); new Thread(new Runnable(){ // Service는보통Thread를이용해백그라운드에서실행시킨다 public void run(){ while(true){ try{ Log.i(DEBUG, " Service is called --" + (++increment) + " --"); Thread.sleep(2000); }catch(InterruptedException ie){ Log.e(DEBUG, " InterruptedException ", ie); } } } }).start(); } public IBinder onBind(Intent intent){ return null; } }백그라운드로 계속 돌기떄문에 onDestory 에서 flag= false로
반응형