Hello,
Firstly, Device.BeginInvokeOnMainThread is obsolete. Please use MainThread.BeginInvokeOnMainThread.
And use Platform.CurrentActivity
to replace of Context. Here is my edited code. You can refer to it.
MainThread.BeginInvokeOnMainThread(() =>
{
#if ANDROID
AndroidX.AppCompat.App.AlertDialog.Builder dialog = new AndroidX.AppCompat.App.AlertDialog.Builder
(Platform.CurrentActivity);
dialog.SetCancelable(false);
dialog.SetTitle("Update Available");
dialog.SetMessage("A new version of this application is available. " +
"Please update to the new version now.");
dialog.SetPositiveButton("Update", (sender, e) =>
{
Android.Content.Intent intent = new Android.Content.Intent(Android.Content.Intent.ActionView, Android.Net.Uri.Parse(string.Format(appSpecificStoreLink, (Platform.CurrentActivity.PackageName))));
Platform.CurrentActivity.StartActivity(intent);
Android.OS.Process.KillProcess(Android.OS.Process.MyPid());
System.Environment.Exit(0);
});
dialog.Show();
#endif
});
Best Regards,
Leon Lu
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.