Xamarin forms using Visual Studio 2017 Community
Already Tried from this most upvoted Question and Anwser
But probably I am not getting direct help for its implementation. Tried a lot but could not make the exact derivatives to call for ICloseApplication and (Activity) (Sorry very new to this) Created Class and interface. But could not go later forward. So if anyone can give me some more detail hint in this resolution or any other example it would be great.
public class CloseApplication : ICloseApplication
{
public void closeApplication()
{
var activity = (Activity)Forms.Context;
activity.FinishAffinity();
}
}
public interface ICloseApplication
{
void closeApplication();
}
I have initially tried:-
private async void CheckConnection()
{
if (Sql_Common.CheckConnection() == false)
{
await DisplayAlert("Network Error!", "Network connection could not be establised to server!", "ok");
System.Diagnostics.Process.GetCurrentProcess().Kill();
}
}
The code in class for CheckConnection:-
public static bool CheckConnection()
{
if (CrossConnectivity.Current.IsConnected)
return true;
else
return false;
}
But it did not quit the application but stayed intact (as if in hang up state) I know I am very near the solution and tried my best but the resolution is not coming.
How about ? (Got from one search) Trying this out till then
Application.Current.Quit();
My main aim:- I want to test at initial level whether the network connection is there or not. If it is not there then it should show a dialog message for No network and exit out from application.