アプリケーションの外でトーストを表示しています。
私はトーストでこのようにうまく動作します:
Toast.makeText(getBaseContext(),"Text").show();
しかし、Dialogで試してみると、
final Dialog dialog_edu = new Dialog(getBaseContext());
dialog_edu.setTitle("Choose Action");
dialog_edu.show();
これを返します:
01-28 18:02:04.734: W/WindowManager(329): Attempted to add window with non-application token WindowToken{41c01dd8 token=null}. Aborting.
01-28 18:02:04.734: E/AndroidRuntime(2626): FATAL EXCEPTION: main
01-28 18:02:04.734: E/AndroidRuntime(2626): android.view.WindowManager$BadTokenException: Unable to add window -- token null is not for an application
コンテキストに「MyAcitivity.this」を使用すると、アプリケーション内では機能しますが、アプリケーションに出かけるときは機能しません。一方、Toast はアプリケーションの内外で機能します。
getActivity() などを使用できることを読みましたが、現在の状態では同じエラーが返されます。
ハンドラーを使用してダイアログのビルドを遅らせようとしても、1 秒間の遅延期間は効果がありません。
では、アプリケーションの内外でダイアログを機能させるにはどうすればよいですか。