Questions tagged [android-connectivitymanager]

159 questions
1
vote
0 answers

How I get client device list which is connected with mobile hotspot

I want to get client device MAC address which is connected with mobile hotspot.I want to get this list in host device which containt hotspot. I already get list in android 9 or lower version but i don't know hot get list android 10 or above…
1
vote
1 answer

android.net.ConnectivityManager$TooManyRequestsException in android while network call

override fun setR2SettingData(cmd: String, status: String) { val requestbuilder = NetworkRequest.Builder() requestbuilder.addTransportType(NetworkCapabilities.TRANSPORT_WIFI) connectivityManager.requestNetwork( …
MARSH
  • 117
  • 1
  • 7
  • 22
1
vote
0 answers

ConnectivityManager.NetworkCallback. onLost called with delay

I have NetworkUtils to monitor the connection state: object NetworkUtils { lateinit var connectivityManager: ConnectivityManager var isConnected = false; private set private object NetworkCallback :…
1
vote
3 answers

Android TRANSPORT_CELLULAR network not available if wifi is connected. How do we make it available?

The moment I get on a wifi connection, the cellular network is completely lost even though the cellular network indicator is definitely on. This is my network request val request = NetworkRequest.Builder().run { …
1
vote
0 answers

Jetpack Compose Navigation Issue| Kotlin ConnectivityManager

I'm using Network Connectivity Manager, In this lambda function when "it" value is false the TOAST will show, BUT after once the Wi-Fi is turned on and the value changes to true it automatically navigates to the composable it shouldn't navigate that…
1
vote
0 answers

Request previously connected network with ConnectivityManager

I'm working with the ConnectivityManager to toggle between networks for a specific task in my app. Basically, I need to connect to a specific network type (with specific network capabilities) while a particular fragment is up, and afterwards, switch…
Sarah
  • 33
  • 1
  • 9
1
vote
0 answers

while android activity running, internet goes off alert not coming after internet off

I am using the following code to show alert dialog to show no internet, scenario 1: internet is off I open the activity it shows alert box no internet. scenario 2(I have problem here): when I open the activity in presence of internet, and then i…
1
vote
0 answers

ConnectivityManager Android. Detect Try again/Cancel dialog button press

I am developing an Android Xamarin Forms app which connects to a wifi programmatically. I used ConnectivityManager and NetworkCallback classes to achieve this. Everything works fine, I can connect to the wifi successfully, pressing the "Connect"…
1
vote
2 answers

Listening to network changes using Connectivity Manager

I am trying to listen to network changes using method registerDefaultNetworkCallback() of conenctivityManager Using the code below from this answer val connectivityManager = cotnext.getSystemService(Context.CONNECTIVITY_SERVICE) as…
David Ibrahim
  • 2,777
  • 4
  • 17
  • 41
1
vote
0 answers

How to get the default Gateway IP from RNDIS Interface in Android

I am trying to build an app that will use USB RNDIS for network communication. I want to get the default Gateway IP that is setup via USB RNDIS on the android phone. However, the code that I wrote only works on a phone that has USB Tethering (phone…
BugShotGG
  • 5,008
  • 8
  • 47
  • 63
1
vote
1 answer

Intercept cancel button press on ConnectivityManger requestNetwork new dialog, API 29

I'm using the ConnectivityManger's requestNetwork API to programmatically connect to a specific network specified by a NetworkRequest object provided as first parameter. I also provide a NetworkCallback to receive notifications related to the status…
Lino
  • 5,084
  • 3
  • 21
  • 39
1
vote
1 answer

Check for WiFi and cellular connection when connected to a VPN

In my Android application, I'm using the following two methods to check if the device is connected to WiFi and if a network connection is available in general. I assume that when the device is connected to WiFi or to a mobile network, also internet…
machinery
  • 5,972
  • 12
  • 67
  • 118
1
vote
1 answer

What's the difference between determining if a network is metered using NetworkCapabilities and ConnectivityManagerCompat?

I have found that there are two ways to detect if the current network is metered: With NetworkCapabilities.hasCapability(NET_CAPABILITY_NOT_METERED) NetworkCapabilities With ConnectivityManagerCompat.isActiveNetworkMetered…
1
vote
1 answer

how to check for NO INTERNET in devices below API level 21

This is my MainActivity, I have registerd my network call back in the onstart. In this code onUnavailable() is never called no matter the device is turned on to the internet wifi or not. I want to check for the internet after clicking a button it…
1
vote
1 answer

How to unit test Android ConnectivityManager

I am building an application by which we can detect the availability of internet connection using ConnectivityManager class but I am not sure how to add unit test for this using Mockito. Please help me writing the unit test case for the following…