私のアプリケーションでは、バックグラウンドスレッドから警告メソッドを呼び出す必要があります。 Contextをバックグラウンドスレッドから取得する必要があります。コンテキストを取得している間、私はトークンのNULLエラーを取得しています。ここで私はApplication.Context
を使用していますし、またthis
働いていない私のコードXamarin Androidのバックグラウンドスレッドからコンテキストを取得する
Handler h = new Handler();
BackgroService.Event +=() =>
{
Action myAction =() =>
{
Dialog dialog = new Dialog(Application.Context);
Android.App.AlertDialog.Builder alert = new Android.App.AlertDialog.Builder(Application.Context, Resource.Style.AlertDialog);
alert.SetTitle("");
alert.SetMessage("MSG");
alert.SetPositiveButton(GetString(Resource.String.ok), (senderAlert, args) =>
{
//MyAction
dialog.Dismiss();
});
dialog = alert.Create();
dialog.Window.SetType(Android.Views.WindowManagerTypes.ApplicationPanel);
dialog.Show();
};
h.PostDelayed(myAction, 1000);
};
です。誰もがこれを正しく行う考えがありますか?