How to get the name of currently connected WiFi network in Android with BroadcastReceiver
-
In my implementation of BroadcastReceiver I want to run some Activity when user is connected to WiFi network with specific name. How can I do that? How can I get the Wifi network name in BroadcastReceiver? And how can I find out that this is wifi connection? Thank you! I already has a code: public class ConnectionChangeReceiver extends BroadcastReceiver { @Override public void onReceive( Context context, Intent intent ) { ConnectivityManager connectivityManager = (ConnectivityManager) context.getSystemService( Context.CONNECTIVITY_SERVICE ); NetworkInfo activeNetInfo = connectivityManager.getActiveNetworkInfo(); NetworkInfo mobNetInfo = connectivityManager.getNetworkInfo( ConnectivityManager.TYPE_MOBILE ); if ( activeNetInfo != null ) { Toast.makeText( context, "Active Network Type : " + activeNetInfo.getTypeName(), Toast.LENGTH_SHORT ).show(); } if( mobNetInfo != null ) { Toast.makeText( context, "Mobile Network Type : " + mobNetInfo.getTypeName(), Toast.LENGTH_SHORT ).show(); } } }
-
Answer:
I would recommend you use http://developer.android.com/reference/android/net/wifi/WifiManager.html#getConnectionInfo%28%29. You can then call http://developer.android.com/reference/android/net/wifi/WifiInfo.html#getSSID%28%29 to get the SSID of your network.
Vitaliy at Stack Overflow Visit the source
Other answers
Take a look at this http://developer.android.com/reference/android/net/wifi/ScanResult.html. The SSID field is the network name. You can use http://developer.android.com/reference/android/net/wifi/WifiManager.html#getScanResults%28%29 to get the latest scan results.
userSeven7s
Related Q & A:
- How To Get Product Code Sygic Android?Best solution by help.sygic.com
- How To Get Product Code For Sygic Android?Best solution by help.sygic.com
- How to get correct URLs in network wide menu (Multisite?Best solution by WordPress
- How to get the IP address of the device in WIFI DIRECT?Best solution by Stack Overflow
- How to check if an IP is currently connected to a server?Best solution by serverfault.com
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
For every problem there is a solution! Proved by Solucija.
-
Got an issue and looking for advice?
-
Ask Solucija to search every corner of the Web for help.
-
Get workable solutions and helpful tips in a moment.
Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.