networkinfo

How to get network state change on android? [duplicate]

只谈情不闲聊 提交于 2019-12-23 05:09:44
问题 This question already has answers here : Android: Internet connectivity change listener (7 answers) Closed last year . 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 use NetworkInfo networkInfo = intent.getParcelableExtra(ConnectivityManager.EXTRA_NETWORK_INFO); It said, this API has been deprecated.

how to detect internet connection in android studio

自作多情 提交于 2019-12-12 03:34:15
问题 I have following code to detect if there is internet connection available or not. But if I have no internet connection only the data connection is "ON" it still works. what I should do? ConnectivityManager cManager = (ConnectivityManager) getSystemService(this.CONNECTIVITY_SERVICE); NetworkInfo ninfo = cManager.getActiveNetworkInfo(); if(ninfo!=null && ninfo.isConnected()) { Toast.makeText(this, "Available",Toast.LENGTH_LONG).show(); } else { Toast.makeText(this, "Not Available",Toast.LENGTH

Using JobService to replace BroadcastReceiver? Network changes and alarms

霸气de小男生 提交于 2019-12-08 04:01:35
问题 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 what kind of network it is and then make decisions based off that answer. I thought, OK, maybe I'll try JobService, but I am not having a lot of luck trying to puzzle out how to use it for my needs. My app is reactive and happens all behind the scenes

NetworkInfo is not properly responding to network changes on phone running Nougat

孤人 提交于 2019-12-06 03:15:20
问题 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 "com.gesslar.threshvote" minSdkVersion 19 targetSdkVersion 25 AndroidManifest.xml <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/> <receiver android:name=".NetworkChangeReceiver" android:enabled="true" android:exported="true"> <intent-filter> <action

NetworkInfo is not properly responding to network changes on phone running Nougat

佐手、 提交于 2019-12-04 08:05:24
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 "com.gesslar.threshvote" minSdkVersion 19 targetSdkVersion 25 AndroidManifest.xml <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/> <receiver android:name=".NetworkChangeReceiver" android:enabled="true" android:exported="true"> <intent-filter> <action android:name="android.net.wifi.WIFI_STATE_CHANGED"/> <action android:name="android.net.conn.CONNECTIVITY