I'm launching a thread that shows a dialog, and if i press the back key (to do some logic to stop the thread), the onKeyDown listener of the activity is not being called. It is because it is being catched by the thread with the dialog... How can i avoid that?
this is my code:
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();
}