私はそれが悪い考えだと言います。ユーザーからの確認が必要な場合は、AsyncTask を 2 つの部分に分割することをお勧めします。最初に一部を実行してから、 onPostExecute()内でダイアログを表示し (UI スレッドで実行されているため)、ユーザーの操作に応じて 2 番目の AsyncTask を起動します。 .
それでも 1 つの AsyncTask で実行したい場合は、次のように実行できます。
final BlockingQueue<Boolean> queue = new ArrayBlockingQueue<Boolean>(1);
this.runOnUiThread(new Runnable() {
public void run() {
// Assuming you have ConfirmUser method which returns boolean
queue.add(ConfirmUser(message));
}
});
Boolean result = null;
try {
// This will block until something will be added to the queue
result = queue.take();
} catch (InterruptedException e) {
// deal with it
}