0

enter image description hereI am using xamarin forms. I need to check whether my app is having the permission of Mobile Data(not internet access). I cannot get any code for this.

Please refer the below images.enter image description here

Manthiram
  • 149
  • 2
  • 13

1 Answers1

0

You can check your device connectivity with Xamarin.Essentials

You will use the API this way :

var current = Connectivity.NetworkAccess;
if (current == NetworkAccess.Internet)
{
   // Connection to internet is available
}
else
{
   //Connection to internet is not available because mobile data is disable
}
  • Hi Estyval, Thank you for your reply. This code is working for iOS. but not android, when i deny or allow, the **current** comes like **NetworkAccess.Internet** – Manthiram Apr 30 '19 at 11:56
  • It's seems like there are some issues with some android phone, you need to dig deep into the platform, here is a link that can helps : https://blogs.infosupport.com/xamarin-android-by-example-monitoring-the-network-status/ – Patrick Tshibanda Apr 30 '19 at 14:57
  • Hi Estyval, I dont need whether network is connected or not. We can restrict the usage of mobile data from settings App Info for App. If we restrict mobile data, then the app is not using internet data even the mobile data is ON. So I want to check the Mobile data is restricted or not. For example, goto any App Info page and goto the DataUsage Tab. On that page, you can see Mobile Data,Wi-Fi, and Background Data with Allow/Deny options. For reference please view the attached images – Manthiram May 01 '19 at 07:36
  • https://stackoverflow.com/questions/6591774/android-api-call-to-determine-user-setting-data-enabled – Patrick Tshibanda May 03 '19 at 09:26