-1
대화 상자를 표시하는 스레드를 시작하고 뒤로 키를 누르면 중지 할 논리를 수행합니다 스레드), 활동의 onKeyDown 수신기가 호출되지 않습니다. 대화 상자가 스레드에 잡혀 있기 때문입니다 ... 어떻게 피할 수 있습니까? 당신이 당신의 대화 취소 할을 할 경우대화 상자가있는 스레드가 뒤로 키를 듣고 있지만 기본 활동이 뒤로 키를 듣고 싶습니다.
public static void getRemoteImage(final String url, final Handler handler) {
Thread thread = new Thread(){
public void run() {
try {
Looper.prepare();
handler.sendEmptyMessage(Util.SHOW_DIALOG);
final URL aURL = new URL(url);
final URLConnection conn = aURL.openConnection();
conn.connect();
final BufferedInputStream bis = new BufferedInputStream(conn.getInputStream());
image = BitmapFactory.decodeStream(bis);
bis.close();
handler.sendEmptyMessage(Util.HIDE_DIALOG);
Looper.loop();
}catch (Exception e) {e.printStackTrace();}
}
};
thread.start();
}
인터럽트 비트 맵의 다운로드를 중지하지 않습니다 : S – Pableras84
은 아마 당신은 당신의 스레드에서이 문제를 추가해야합니다 : '캐치 (의 InterruptedException e)는 {는 Thread.currentThread()가 인터럽트();. }' – MarchingHome
여기에 더 많은 정보가 있습니다 : [link] (http://stackoverflow.com/questions/5361624/how-to-cancel-a-thread) – MarchingHome