0

I am displaying current connected WiFi SSID name in my android app..it displaying current connected WiFi SSID name.

problem is printing "rakesh" like this Its printing along with this symbol" " can anyone help me

   ConnectivityManager connectivityManager = (ConnectivityManager) 
    context.getSystemService(Context.CONNECTIVITY_SERVICE);
   NetworkInfo wifiInfo = connectivityManager.getNetworkInfo(ConnectivityManager.TYPE_WIFI);
    if(wifiInfo.isConnected() == true){
        WifiInfo localInfo = wifiManager.getConnectionInfo();
        Details = "Connected to " + localInfo.getSSID();

    }else{
        Details = "Not Connected";
    }
Rajesh Satvara
  • 3,842
  • 2
  • 30
  • 50
rakesh
  • 49
  • 2
  • 8
  • check this for more http://stackoverflow.com/questions/3531940/how-to-get-name-of-wifi-network-out-of-android-using-android-api – Rajesh Satvara Sep 23 '16 at 10:42

4 Answers4

1

try this

WifiManager wifiManager = (WifiManager) getSystemService (Context.WIFI_SERVICE);
WifiInfo info = wifiManager.getConnectionInfo ();
String ssid  = info.getSSID();
Ramesh Prajapati
  • 654
  • 6
  • 10
0

Try using: android.net.wifi.WifiInfo.getSSID

Just_someone
  • 1,293
  • 1
  • 11
  • 13
0

Try this.

 WifiManager wifiMgr = (WifiManager) getContext().getSystemService(context.WIFI_SERVICE);

    WifiInfo wifiInfo = wifiMgr.getConnectionInfo();
    String ssid = wifiInfo.getSSID();

Add Following Permission on your Manifest.

 <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
Quantum4U
  • 35
  • 4
0

A little late answer but from the documentation of WifiInfo.getSSID() :

If the SSID can be decoded as UTF-8, it will be returned surrounded by double quotation marks

which seems to be the problem in your case. If you don't need the " characters just remove them from the String.

daidalos
  • 66
  • 3