Hello,
If you only switch off the internet on your Windows machine, the Android Emulator can't test the state. Please try to debug on your real device. Or open the airplane mode in Setting under NetWork&Internet of your Android Emulator.
But VS can't debug in airplane mode on my side, because it is unable to connect debugger-agent. I'm not sure if this issue exists on your side.
My testing on Android Emulator:
public App()
{
InitializeComponent();
var current = Connectivity.NetworkAccess;
if (current == NetworkAccess.Internet)
{
MainPage = new MainPage();
}
else
{
MainPage = new NoInternetPage();
}
}
When I turn on airplane mode and reopen the app, it will go to NoInternetPage
.
Best Regards,
Wenyan Zhang
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.