in Education by
I have an app that needs to be connected to a specific network. I already have a code to force the device to connect to that network, but every time I open a different screen it repeats the process and it takes like 2 or 3 seconds. So, instead of forcing to connect every time I want to ask in what network it is in that moment, so, if it's the incorrect network it has to connect to the correct one, and if it's in the correct one it doesn't have to do anything. How can I get the network's name? Below is the code I am using, but when I debug it it says the SSID name is "", so every time I check if the name is correct it says that is false and it connects again to the network. public static string GetSSID() { WifiManager wifiManager = (WifiManager)(Android.App.Application.Context.GetSystemService(Context.WifiService)); if (wifiManager != null && !string.IsNullOrEmpty(wifiManager.ConnectionInfo.SSID)) { return wifiManager.ConnectionInfo.SSID; } else { return "WiFiManager is NULL"; } } JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)

1 Answer

0 votes
by
At first, you need to grant the app the permission about the location. And then you need to grant the permisson by the ActivityCompat.RequestPermissions before you get the information of the wifi. The official document about run-time permission: https://docs.microsoft.com/en-us/xamarin/android/app-fundamentals/permissions?tabs=windows In addition, you can also try the following code to get the SSID after the permission granting. ConnectivityManager connectivityManager = (ConnectivityManager)Android.App.Application.Context.GetSystemService(Context.ConnectivityService); NetworkInfo networkInfo = connectivityManager.ActiveNetworkInfo; var ssid = networkInfo.ExtraInfo;

Related questions

0 votes
    I have an app that needs to be connected to a specific network. I already have a code to force ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 7, 2022 in Education by JackTerrance
0 votes
    Please see the code public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView( ... Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 19, 2022 in Education by JackTerrance
0 votes
    Please see the code public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView( ... Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 18, 2022 in Education by JackTerrance
0 votes
    Please see the code public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView( ... Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 18, 2022 in Education by JackTerrance
0 votes
    Please see the code public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView( ... Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 18, 2022 in Education by JackTerrance
0 votes
    Hints: Peers,Hub,WiFi,Layout, Repeater 1) A dash is a central controller device in a network 2) A dash ... other are called dash Select the correct answer from above options...
asked Dec 28, 2021 in Education by JackTerrance
0 votes
0 votes
    I'm totally new to Xamarin, so please be patient! Somehow Xamarin adds a mysterious Margin to all my ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jul 8, 2022 in Education by JackTerrance
0 votes
    i want to run a task every 5 minutes. i've tried to solve it with an IntentService and ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jun 26, 2022 in Education by JackTerrance
0 votes
    All, I am trying to use syncfusion data grid in xamarin forms now.I have installed trial version as ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jun 23, 2022 in Education by JackTerrance
0 votes
    We have a Xamarin Forms View with just a Toolbar and a WebView. ContentPage xmlns="http://xamarin.com/schemas/2014/ ... " Title="TestApp" x:Class="TestApp.Client.Views.MainPage">...
asked May 22, 2022 in Education by JackTerrance
0 votes
    I've noticed on Marshmallow (e.g. Nexus 6P) and also on some more recently updated Lollipop phones ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jul 20, 2022 in Education by JackTerrance
0 votes
    I would like to detect the presence of unsecured wifi network in my app. Is there any public iOS ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 7, 2022 in Education by JackTerrance
0 votes
    I would like to detect the presence of unsecured wifi network in my app. Is there any public iOS ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 5, 2022 in Education by JackTerrance
...