핸들메시지를 보내서 토스트를 띄울려고 하는데요~
실행이 안되네요..
조언 부탁 드립니다~
public int onStartCommand(Intent intent, int flags, int startId)
{
super.onStartCommand(intent, flags, startId);
lThread = new Thread(lock);
lThread.setDaemon(true);
lThread.start();
bThread = new Thread();
bThread.setDaemon(true);
bThread.start();
return START_REDELIVER_INTENT;
}
class bThread extends Thread{
Handler mHandler;
bThread(Handler handler){
mHandler = handler;
}
public void run(){
while(true){
mHandler.sendEmptyMessage(0);
}
}
}
Handler mHandler = new Handler(){
public void handleMessage(Message msg){
if(msg.what == 0){
Toast toast = Toast.makeText(getApplicationContext(), "배터리가 부족합니다.", Toast.LENGTH_SHORT);
toast.show();
}
}
};
Handler 에서 오버라이드 해야 하는 메소드 이름은 handleMessage 이므로, HandleMessage 에서 handleMessage 로 메소드 이름만 바꿔 주시면(대소문자) 문제는 해결될 것 같네요.