How to connect to local network first instead of internet in C# Xamarin Android app?

前端 未结 3 1071
感情败类
感情败类 2020-12-07 05:53

I have a Xamarin Android app. It connects to a “No Internet based Wifi router” for some IOT devices. But it also needs to use mobile’s cellular data for storing some informa

3条回答
  •  失恋的感觉
    2020-12-07 06:11

    The solution I can think of is that you can try to use Xamarin.Essentials and check the profile of the connection, and use this to force the requests to your Wifi, and the other requests through cellular data

    var profiles = Connectivity.ConnectionProfiles;
    if (profiles.Contains(ConnectionProfile.WiFi))
    {
        // Active Wi-Fi connection.
    }
    

    The documentation can be found here.

提交回复
热议问题