E/AndroidRuntime(8068): FATAL EXCEPTION: Thread-12
E/AndroidRuntime(8068): FATAL EXCEPTION: Thread-12
위와 같은 에러가 발생했다
상세 메세지는 아래와 같다.
Only the original thread that created a view hierarchy can touch its views.
구글링 해보니
http://binsolb.tistory.com/entry/CalledFromWrongThreadException
이 사이트를 찾았따~!
이를 응용해서 내가 만든건....
아래와 같다~!
로딩중이라는걸 뱅글 뱅글 돌면서 보여주고 진행과정을 숫자로 보여주는것이다.
public void init() {
BackRunnable runnable = new BackRunnable();
Thread thread = new Thread(runnable);
thread.setDaemon(true);
thread.start();
}
boolean runFlg = true;
int loadPercent = 0;
class BackRunnable implements Runnable {
public void run() {
while (runFlg) {
loadPercent = videoView.getBufferPercentage();
Log.i("BackRunnable", ""+loadPercent);
try { Thread.sleep(10); } catch (InterruptedException e) {;}
Message msg = Message.obtain(mHandler, 0,loadPercent, 0);
mHandler.sendMessage(msg);
}
}
}
Handler mHandler = new Handler() {
@Override
public void handleMessage(final Message msg) {
if (runFlg) {
runOnUiThread(new Runnable() {
@Override
public void run() {
// Log.i("mHandler", ""+msg.arg1);
txtLoadPersent.setText(msg.arg1 + "%");
if (msg.arg1 == 100) {
prgsStmLoad.setVisibility(View.GONE);
txtLoadPersent.setVisibility(View.GONE);
runFlg = false;
}
}
});
}
}
};