Questions tagged [networkinfo]
20 questions
15
votes
1 answer
NetworkInfo has been deprecated by API 29
I wanted to check the network connection. So, I used ConnectivityManager.activateNetworkInfo.isConnected
unfortunately, that's deprecated in API 29.
private fun isOnline(): Boolean {
val connectivityManager =…

A.R.B.N
- 1,035
- 2
- 10
- 20
11
votes
3 answers
How to get WIFI SSID in Android 9.0(PIE)?
How to get WIFI SSID in Android 9.0(PIE)? My code is working fine till android version 8.1.0 but it is not working on Android 9.0
ConnectivityManager connManager = (ConnectivityManager) activity.getSystemService(Context.CONNECTIVITY_SERVICE);
…

Abhinav Tiwari
- 131
- 1
- 1
- 5
5
votes
3 answers
Difference between NetworkInfo.isConnected() and NetworkInfo.getDetailedState() == NetworkInfo.DetailedState.CONNECTED. What to use?
I want to know which method will be precise to check the network state for successfully getting connected.

Shubham Dadhich
- 127
- 1
- 7
5
votes
1 answer
NetworkInfo is not properly responding to network changes on phone running Nougat
Preface: This is working just fine on a phone running 6.0.1. but on my phone that is running 7.1.1, it is not, as shown below.
build.gradle (Module:app)
compileSdkVersion 25
buildToolsVersion "25.0.0"
applicationId…

the_gesslar
- 379
- 3
- 13
2
votes
2 answers
Getting "BLOCKED" network state when Android's data saver is off
I am developing an app to be used on a specific tablet running Android 7.0. I'm using a Service to send periodic DatagramPackets. I can only use mobile networks. I check the connectivity status using ConnectivityManager, NetworkInfo and…

Jon
- 891
- 13
- 32
1
vote
2 answers
How to check the connection status in Android avoiding StrictMode
I created a function that returns a boolean based on the presence of an internet connection, this function it is called different times from different java classes.
The only way that I find to use it is to use the StrictMode.setThreadPolicy (i know…

Mattia
- 1,057
- 2
- 17
- 33
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…

Shreyas patne
- 25
- 7
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…

Amit Ghosh
- 63
- 6
1
vote
0 answers
Android In app Updates Asking for Wifi while it is on with wifi shared by cell phone
I want to update an android app with android in app update but I have some problem if the phone is connected to a WIFI provided by a cell phone (sharing its cellular network).
In app Update seems to works like this:
When update is found and…

Dennis BORDET
- 9
- 1
1
vote
0 answers
Using JobService to replace BroadcastReceiver? Network changes and alarms
It's becoming increasingly frustrating trying to get NetworkInfo working. I posted a question, but I guess people haven't seen it. Anyway, I really need a solution based on my flow below. I need to know when my network changes so I can determine…

the_gesslar
- 379
- 3
- 13
1
vote
2 answers
Difference between `isConnected()` and `isAvailable()` in android `NetworkInfo`
I'm trying to check if the device is connected to internet or not. I have the below implementation to do that
public static boolean isConnectedToNetwork(Context context) {
ConnectivityManager connectivityManager =
(ConnectivityManager)…

arjun
- 3,514
- 4
- 27
- 48
1
vote
1 answer
networkInfo.isConnected() method return true even there is no internet?
i develop this app , in the main activity i check the internet connection as the following :
ConnectivityManager connectivityManager = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo networkInfo =…

Yazan Khateeb
- 61
- 1
- 9
1
vote
6 answers
How to get network state change on android?
I have broadcast receiver for "CONNECTIVITY_CHANGE". When I print the extra using this:
intent.getExtras().toString()
I can see that if I disable WIFI, I receive 2 network change.
WIFI DISCONNECTED
MOBILE CONNECTED
However, when I try to…

Adrian
- 273
- 1
- 4
- 14
1
vote
2 answers
How to find internet is working or not
In device when i enable the internet data it shows E in network. but i dont have data pack in my sim and internet is not working in any apps. I have used this code it returns true that internet is there. In this case how to find whether internet is…

YLS
- 1,475
- 2
- 15
- 35
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