Questions tagged [android-connectivitymanager]
159 questions
0
votes
2 answers
ConnectivityManager returns true even if there are no active networks
I am trying to detect if there are any active internet connections (WIFI or MOBILE INTERNET). The code is as follows:
private boolean haveNetwork() {
ConnectivityManager connMgr =
(ConnectivityManager)…
user15256805
0
votes
0 answers
Android 10 requestNetwork dialog is continuously shown if network is already configured
In my app, I am attempting to call ConnectivityManager.requestNetwork(networkRequest, networkCallback) to prompt the user to connect to a particular WiFi network. Normally this works as expected; the system dialog with the text Device to use with…

Cowabunghole
- 191
- 1
- 8
0
votes
1 answer
Unit test isNetworkAvailable() in Android
I have following unit test :
@Test
fun givenServerResponse200_whenFetch_shouldReturnSuccess() {
`when`(context.isNetworkAvailable()).thenReturn(true)
…

Ali
- 9,800
- 19
- 72
- 152
0
votes
0 answers
My Andoid app is not working on phone and showing message " bookhub has stopped "? i was trying to connect my app to internet
I tried to connect my app to the internet. I run the following code
This is the set of code I entered in "ConnectionManager.kt" Class
import android.content.Context
import android.net.ConnectivityManager
import android.net.Network
import…

SnazzyGill
- 13
- 5
0
votes
0 answers
How to block and allow other apps from Accesing the internet in android programatically?
My idea is to to design a android apps that allow or block internet traffic of selected apps acording to my wish in non-rooted phone.
I know it is possible, but anyone please help me in achieving this.
There are some apps like mobiwol etc., which…

kathirvel
- 11
- 2
0
votes
1 answer
Internet connection status monitoring through observables runs only once
I want to have application wide internet connection monitoring, for this purpose I'm using rxjava, I made a util class and got static method for connection state like this:
val connectivityManager =…

blackHawk
- 6,047
- 13
- 57
- 100
0
votes
2 answers
Is WorkManager the right solution for me?
I have following requirement in my app.
1. I select some files & click Upload button. On clicking Upload button, the app exits. (I am enqueueing the request & finishing the activity).
2. Once the app exits, these files need to get synced to…

AndroidGuy
- 1,270
- 4
- 15
- 32
0
votes
1 answer
Xamarin/special wifi permissions for android 10?
I've got an app that connects to a wifi access point, then connects to a local server on port 50,000. Works fine on API < 29. But in 29, I have to use ConnectivityManager instead of WifiManager. Got that working no problem. The problem is connecting…

drussell
- 11
- 2
0
votes
1 answer
How to use ConnectivityManager.NetworkCallback()
I want to use ConnectivityManager.NetworkCallback() to use to take the connected wifi SSID of the android device.
private ConnectivityManager.NetworkCallback mNetworkCallback = new ConnectivityManager.NetworkCallback() {
@Override
public…

Hilton
- 337
- 6
- 19
0
votes
2 answers
Android ConnectivityManager NetworkCallback crash
I'm new in Android world (as user but also as developer) and my Android App crash when execute myWebView.loadUrl("https://www.google.com"), but I don't understand why...
The goal is monitoring internet connection while the app is running:
If the…

Stefano
- 297
- 2
- 4
- 15
0
votes
1 answer
ConnectivityManager Network is null when specifying to use only wifi
I am trying to store a wifi network (and eventually cellular network) through ConnectivityManager for use later in my program to send data specifically through a local Wifi or cellular network simultaneously. I have followed this post (Make Android…

westerie
- 82
- 8
0
votes
1 answer
How to get an event for wifi getting enabled or disabled
What is a way to listen and receive an event when Wifi is enabled or disabled on Android?
Note that I am not looking for connectivity to the internet. I am just looking for an event which says wifi in the wifi settings was enabled.

AdeleGoldberg
- 1,289
- 3
- 12
- 28
0
votes
2 answers
Check internet connection with target sdk 29 and without deprecated methods
I have the
compileSdkVersion 29
and
targetSdkVersion 29
in my android app. And to check if there is a connection I use the next code:
val connectivityManager = context.getSystemService(Context.CONNECTIVITY_SERVICE) as ConnectivityManager?
return…

Alex D.
- 1,424
- 15
- 40
0
votes
1 answer
How to implement Internet Connection listener for each Activity using JobScheduler and BroadcastReceiver
I want to check if user has available connection to the internet and show Snackbar for him or other custom action.
App's minSdk is 23 (Android 6.0).
Since Android 7.0 there were some changes to BroadcastReceiver and receiving connection status. Now…

martin1337
- 2,384
- 6
- 38
- 85
0
votes
1 answer
ConnectivityManager.TYPE_WIFI is showing deprecated in code.I had use Network Capabilities in above M version , want to remove warning of deprecated
I want to remove the warning which is showing in the code below m version.I had use below code which is working good but still want to remove the warning which is showing in line ConnectivityManager.TYPE_WIFI.Can below warning be removed which is…

Ankit Gupta
- 64
- 10