I am using c# and Xamarin.Android.
I want to create an app, and when it realized it has a new version, it will let user download the new version and force itself off.
So I used AlertDialog.
My code:
if (NeedUpdate)
{
alertDialog = null;
builder = new AlertDialog.Builder(this);
alertDialog = builder
.SetTitle("New Version")
.SetMessage("please update the app to the latest version.")
.SetPositiveButton("OK", (s, e) =>
{
})
.Create(); //Create alertDialog
alertDialog.Show();
var dialog = new AlertDialog.Builder(this);
}
In my code, NeedUpdate is a variable to store whether there's a new version.
But the question has begun.
In this app, the AlertDialog is translucent.
So the user can click on the translucent area to close it (without triggering the event I wrote).
I just want to ask, how to avoid user to close it without triggering the event I wrote, or if that's a event for what I said?
I admit, it's a very bad idea that force my users to update the app.
But I just want to know how to achieve it. Who have solutions?
PS:Some parts of the article is translated by machine, include this sentence.
Well i guess you could do the following
alertDialog.SetCancelable(false);
Also if the above is what you want have you checked the Google Play core's playstore update plugin?
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.