Questions tagged [android-connectivitymanager]
159 questions
0
votes
0 answers
How to detect if the user is connected to the internet in android (java)
I had the following code that worked perfect to detect if the user was connected to the internet but I have noticed that it is using deprecated API :
import android.content.Context;
import android.net.ConnectivityManager;
import…

Eldestornillador
- 77
- 6
0
votes
2 answers
Checking for Internet Connection in Android/Java Code
I have been using the following code (acquired from the web) to check for Internet connection in my Android (web) app.
import android.content.Context;
import android.net.ConnectivityManager;
public class DetectConnection {
public static boolean…
user16779236
0
votes
1 answer
Controlling network connectivity on Android
I am making a sample app, only to see, how to monitor the network connectivity on Android.
For that I follow this document:
https://developer.android.com/training/monitoring-device-state/connectivity-status-type
Since I am not getting the results I…

Michel
- 10,303
- 17
- 82
- 179
0
votes
1 answer
How to check android mobile network mode setting state "Always on" or "Auto" or "Always off" programmatically?
I need to get mobile network setting state in WearOS: "Always on" or "Auto" or "Always off".
Exactly need to differentiate these states in code
maybe there is a way through ConnectivityManager or TelephonyManager or Settings.Secure?
I've also…

Alexey Kolosov
- 140
- 2
- 15
0
votes
0 answers
WebView shows "no_internet_layout" on error received even when there is an internet connection. Android Studio
I made a webview app but there is one error which is bothering me.
The error is with the "webView.setWebViewClient(new WebViewClient()); and onErrorReceived"
I created a no_internet_layout to show when there is no connection and added it to the…

Richard owusu
- 1
- 1
0
votes
0 answers
How to get notified when the internet connectivity is available when the application is in background without using broadcast receivers
I have an application in which need to do some operation when internet is available even if app is in background or not available in the recent list.
I do not want to use broadcast receivers.
How can I achieve this.?

Nikitha
- 49
- 5
0
votes
0 answers
How can I connect the internet by wifi?
When android device is not connected to the Internet,
I'm going to check if Wi-Fi can be connected with connection live data and connect to a specific Wi-Fi.
ConnectionLiveData
private val TAG = "ConnectionLiveData"
class…

Polaris Nation
- 1,085
- 2
- 18
- 49
0
votes
1 answer
When my android app is coming to foreground sometimes ConnectivityManager.activeNetwork object is null even when there is a good internet connection
I am working on android app where I need to check for internet connection if available I hit the api inside onStart method else No-Internet popup opens. But sometimes(not everytime) when my app comes to foreground after hitting home button and then…

Tac_1
- 35
- 8
0
votes
1 answer
Network Capabilities is showing true, when vpn connected but net disconnected
class CheckPresentConnection(private val context: Context) {
private lateinit var cm: ConnectivityManager
fun isNetworkAvailable(): Boolean{
cm = context.getSystemService(CONNECTIVITY_SERVICE) as ConnectivityManager
val capabilities =…

Rick
- 3
- 1
- 1
0
votes
1 answer
How to get Network Info - Android
This is my code below:
@SuppressWarnings("BooleanMethodIsAlwaysInverted")
private boolean isNetworkConnected() {
ConnectivityManager cm = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
return cm.getActiveNetworkInfo()…
user16257123
0
votes
1 answer
How to unregister a registerDefaultNetworkCallback (new ConnectivityManager.NetworkCallback () ...)
Using this code taken from:
https://developer.android.com/training/basics/network-ops/reading-network-state
I register a DefaultNetworkCallback:
connectivityManager.registerDefaultNetworkCallback(new ConnectivityManager.NetworkCallback() {
…

canel
- 81
- 2
- 7
0
votes
0 answers
How to check a password for an SSId is right or not on android 10 APP
I am implementing an APP through Xamarin.
The APP need to check a password for an SSId is right or not.
So I issued a wifi connection to check it.
Here is the code.
var specifier = new WifiNetworkSpecifier.Builder()
.SetSsid("Target_SSID")
…

CC.Wang
- 111
- 1
- 12
0
votes
1 answer
Network connection check always return false for some Android devices
I am using this methods for check network connection but some users getting "no internet connection" error even they have connected to internet. Users reviewed with; Huawei Mate 10 Lite, LGE V20, Asus Zenfone, Samsung Galaxy A8
My methods:
private…

furkanbzkurt
- 296
- 4
- 14
0
votes
1 answer
Android Get Status of Wifi Connection
I'm currently using NetworkRequest and NetworkCallback approach (recommended by Google official) to get status of Wifi connection, and it works partially.
I'm expecting the onUnavailable() will get called when: close app -> turn off Wifi -> launch…

Sam Chen
- 7,597
- 2
- 40
- 73
0
votes
0 answers
Android Internet Connectivity Listener Problem
I would like to put a Network Detector in an Android application, to inform a Screen immediately the Network state even if that state is changing. I have study similar questions in:
Android: Internet connectivity change listener
So my Java code in…

Psiloritis
- 17
- 5