안드로이드 개발 질문/답변
(글 수 45,052)
public void onCreate(Bundle savedInstanceState) {
.....
mUpdateTimer = new Timer();
mUpdateTimer.schedule(new TimerTask() {
@Override
public void run() {
//Looper.prepare();
UpdateMethod();
//Looper.loop();
}
}, 500, mUpdatePeriod);
}
....
}
private void UpdateMethod() {
if(mTimeoutCounter>=mMaxTimeoutCount && mMaxTimeoutCount>-1) {
if (D) {
Log.i("신호",MyView2.Sinho+"");
if(MyView2.Sinho == 1){
sendMessage("1");
mTimeoutCounter = 0;
}
}else{
if( mMaxTimeoutCount>-1 )
mTimeoutCounter++;
}
....
위와 같이 구동하면
java.lang.RuntimeException: Can't create handler inside thread that has not called Looper.prepare()
에러가 나고
주석부분을 제거 하면, 에러는 나오지 않지만 값이 안나옵니다....
(Log.i("신호",MyView2.Sinho+""); 에 대한 신호가 나오질 않습니다. )
어렵네요 ㅠㅠㅠ
블루투스 모듈 연동 어플이라서... 아래와 같은 다른 핸들러를 쓰고 있긴한데... 중복되서 그런가요??
(검색해보니 어디서 중복되서 그런거라고....)
// The Handler that gets information back from the BluetoothChatService
private final Handler mHandler = new Handler() {
@Override
public void handleMessage(Message msg) {
switch (msg.what) {
.....
아.. 말로는 설명을 못하겠지만.. 아래 사이트를 참조하시면 도움이 되지 않을까 생각되네요.
http://huewu.blog.me/110115454542
Handler와 Looper에 대해 좀 자세히 알 수 있습니다.
도움 되시길....