@Override
public int onStartCommand(Intent intent, int flags, int startId) {
Log.d(TAG,"onStartCommand() 호출됨");

if(intent != null)
{
String command = intent.getStringExtra("command");
if(command != null)
{
if(command.equals("start")) {
PrintThread thread= new PrintThread();
thread.start();

}
}
}

return super.onStartCommand(intent, flags, startId);

}

class PrintThread extends Thread{
public void run(){
for(int i=0;i<100;i++){
Log.d(TAG, i + " 서비스 반복됨");

try{
Thread.sleep(100);
}
catch (Exception e){
e.printStackTrace();
}
}
}
}


'Android' 카테고리의 다른 글

로컬서버 모바일에서 돌리기  (0) 2017.05.08
view 가운데 놓기  (0) 2017.04.23
앱종료시 저장 SharedPreferences  (0) 2017.02.12
단축키  (0) 2017.02.05
logcat  (0) 2012.02.04

+ Recent posts