올바른 Toast 예외 처리, Unable to add window -- token......is not valid; is your activity running?

740 단어 android
해결책
새 Thread(new Runnable() {@Override public void run() {Looper.prepare(), Toast.makeText(Activity.this, 콘텐츠, Toast.LENGTH SHORT).show(), Looper.loop(),}.start();
문제 원인, 이 글 참조: Toast 원본 깊이 분석https://blog.csdn.net/m0_37700275/article/details/83038714#commentBox
새로운 문제가 발견되었습니다. 이상 해결 방안을 사용하여 이상 Caused by:java.lang.RuntimeException: Only one Looper may be created per thread 해결책은 new Thread(new Runnable() {@Override public void run () {if(Looper.my Looper() = =null) {//check already Looper is associated or not. Looper.prepare ();//No Looper is defined Sofinew one new
     Toast.makeText(Activity.this, "  ", Toast.LENGTH_SHORT).show();
    
            Looper.loop();
}

}).start();

좋은 웹페이지 즐겨찾기