In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-05 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
Most people do not understand the knowledge points of this article "what is the method of android access and monitoring mobile phone network status?", so the editor summarizes the following content for you, detailed content, clear steps, and has a certain reference value. I hope you can get something after reading this article. Let's take a look at this "what is the method of android access and monitoring mobile phone network status".
1. Obtain whether the current mobile networking method is WiFi or mobile 4G data private boolean getNetworkType () {ConnectivityManager mConnectivity = (ConnectivityManager) getSystemService (Context.CONNECTIVITY_SERVICE); / / check the network link NetworkInfo info = mConnectivity.getActiveNetworkInfo (); int netType = mConnectivity.getActiveNetworkInfo (). GetType () If (netType = = ConnectivityManager.TYPE_WIFI) {/ / WIFI ChangYouLog.i (TAG, "currently WIFI connection isConnected =" + info.isConnected ()); return info.isConnected ();} else if (netType = = ConnectivityManager.TYPE_MOBILE) {/ / MOBILE ChangYouLog.i (TAG, "currently mobile network connection isConnected =" + info.isConnected ()); return info.isConnected () } else {ChangYouLog.i (TAG, "currently no network connection isConnected =" + info.isConnected ()); return false 2. Monitor mobile network changes private class MyBroadcastReceiver extends BroadcastReceiver {@ Override public void onReceive (Context context, Intent intent) {if (intent.getAction (). Equals (ConnectivityManager.CONNECTIVITY_ACTION)) {/ / monitor network connection / / get the NetworkInfo object NetworkInfo info = intent.getParcelableExtra (ConnectivityManager.EXTRA_NETWORK_INFO) If (info! = null) {/ / if the current network connection is successful and the network connection is available if (NetworkInfo.State.CONNECTED = = info.getState () & & info.isAvailable ()) {if (info.getType () = = ConnectivityManager.TYPE_WIFI) {ChangYouLog.i (TAG) "connect to WiFi") } else if (info.getType () = = ConnectivityManager.TYPE_MOBILE) {ChangYouLog.i (TAG, "connecting Mobile Network data"); CYouLbyMicroClient.getInstance () .gameEvent ("Network_4G_reminder") }} else {ChangYouLog.i (TAG, "Network disconnected");}}
Note: network status permissions need to be added
The above is the content of this article on "what is the method of android obtaining and monitoring mobile phone network status". I believe we all have a certain understanding. I hope the content shared by the editor will be helpful to you. If you want to know more related knowledge, please pay attention to the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.