Questions tagged [android-connectivitymanager]

159 questions
6
votes
1 answer

WifiInfo returning null

I have been working on this for a few days after following this guide online. I am using target API 30 (building on a device using Android 11). Trying to get the Wifi SSID using networkCapabilities this keeps returning null whereas the depreciated…
958
  • 178
  • 1
  • 9
6
votes
1 answer

ConnectivityManager.NetworkCallback calls missing when a VPN is connected/disconnected

My Android app has registered ConnectivityManager onAvailable and onLost NetworkCallbacks, but they are not called when a VPN (I'm testing with OpenVPN app) is connected or disconnected. They do get called when cellular network is…
Juha
  • 349
  • 2
  • 11
6
votes
1 answer

Get Android DhcpInfo connected via Ethernet

How to get DhcpInfo() (gateway ip, netmask, dns, etc) of android device connected via Ethernet? I know how to get it if device connected via Wifi and using ACCESS_WIFI_STATE permission: WifiManager wifi = (WifiManager)…
5
votes
0 answers

Android 10 (API29) connecting via ConnectivityManager caches password and fails

I've implemented connection to a IoT device via WiFi access point it's providing. I'm using requestNetwork method of ConnectivityManager and I'm providing WifiNetworkSpeficier with SSID pattern and password. Problem is that it looks like API 29 is…
5
votes
0 answers

WiFi Network Connection keeps disconnecting on Android Q

I use the WiFi Network Request API to connect to a network on android Q. The connection becomes available but gets lost. Here is my code public void registerNetworkCallback() { try { ConnectivityManager…
Sam
  • 446
  • 7
  • 17
5
votes
5 answers

ConnectivityManager.getActiveNetworkInfo() / NetworkInfo is deprecated in API 29. What's an alternative?

Seem like whole NetworkInfo is deprecated on API 29. So I am looking for an alternative to check if the network is connected. E.g. alternative to connectivityManager.activeNetworkInfo?.isConnected == true Sidenote: I know there is a callback now,…
hrach
  • 2,443
  • 2
  • 26
  • 37
5
votes
1 answer

How to detect Network change and change activity from A to B when Network is connected

I have SplashActivity, Activity A and Activity B. When the Internet is not available, Splash activity redirects to Activity A and when Internet is available and is connected SplashActivity redirects to Activity B. I would like to immediately close…
Bir Nepali
  • 429
  • 1
  • 8
  • 20
5
votes
2 answers

how to check slow network connection in android

I have to show a page if network connection is slow iam checking the network by using this code ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo info =…
Lassie
  • 984
  • 11
  • 25
4
votes
0 answers

How do I avoid "Something came up" error using ConnectivityManager.requestNetwork when the screen is off?

I've got a Foreground Service (extends androidx.core.app.JobIntentService) that gets work enqueued when a push notification comes in. Its job is to connect to the Wi-Fi AP of an IoT device and download a video file. It is supposed to do this whether…
4
votes
2 answers

Dialog in Wi-Fi Network Request API

I'm using the new API 29 for connecting the device to a wifi network in an Android 10 device: private val connectivityManager: ConnectivityManager by inject() override fun connectToNetwork(ssid: String, password: String) { val…
Rui
  • 936
  • 10
  • 21
4
votes
3 answers

ConnectivityManager Networkcallback doesn't catch connection to wifi network with no internet connection

I have a device to which my app can connect via WIFI, the device however doesn't have internet. I implemented a NetworkCallback to catch changes in connectivity as such: public class ConnectivityNetworkCallback extends…
Keselme
  • 3,779
  • 7
  • 36
  • 68
3
votes
1 answer

How to give WiFi higher priority than Ethernet on android 9?

I'm working on android 9 and I want to give preference to WiFi over Ethernet. I tried giving wifi higher priority than ethernet in my config.xml file as shown below but still my ethernet has higher priorty.
3
votes
1 answer

How to detect slow internet connection in android app

I want to detect if a phone has a slow internet connection or high-speed internet. Now they have deprecated NetworkInfo and suggesting that we should use ConnectivityManager#getNetworkCapabilities using this I am able to get the signal strength but…
Harsh Shah
  • 2,162
  • 2
  • 19
  • 39
3
votes
1 answer

How does Google validate network connectivity when using NET_CAPABILITY_VALIDATED?

Out of curiosity, what method is Google using to validate a working internet connection? Are they hitting a universal endpoint? https://developer.android.com/reference/android/net/NetworkCapabilities#NET_CAPABILITY_VALIDATED Any link to some AOSP…
Grant Park
  • 1,004
  • 1
  • 9
  • 29
3
votes
1 answer

How to synchronously retrieve network status for certain transport types as of Android 22?

I changed the question title since Kiskae provided a solution to the broader problem which makes the question about wrapping a callback API needless for the particular problem. The former question title was: How to wrap asynchronous callback into…
JJD
  • 50,076
  • 60
  • 203
  • 339
1
2
3
10 11