Android Context Get getCurrentSsid(Context context)

Here you can find the source of getCurrentSsid(Context context)

Description

get Current Ssid

Declaration

private static String getCurrentSsid(Context context) 

Method Source Code

//package com.java2s;

import android.content.Context;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.net.wifi.WifiInfo;
import android.net.wifi.WifiManager;
import android.text.TextUtils;

public class Main {
    private static String getCurrentSsid(Context context) {
        String ssid = null;// w ww  . jav a2 s. c  o m
        ConnectivityManager connManager = (ConnectivityManager) context
                .getSystemService(Context.CONNECTIVITY_SERVICE);
        NetworkInfo networkInfo = connManager
                .getNetworkInfo(ConnectivityManager.TYPE_WIFI);
        if (networkInfo.isConnected()) {
            final WifiManager wifiManager = (WifiManager) context
                    .getSystemService(Context.WIFI_SERVICE);
            final WifiInfo connectionInfo = wifiManager.getConnectionInfo();
            if (connectionInfo != null
                    && !TextUtils.isEmpty(connectionInfo.getSSID())) {
                ssid = connectionInfo.getSSID();
            }
        }
        return ssid;
    }
}

Related

  1. getCornerPaint(Context context)
  2. getCornerRadius(Context context)
  3. getCurProcess(Context context)
  4. getCurrentHome(Context c)
  5. getCurrentLocationByName( Context context)
  6. getDataFile(Context context, String fileName)
  7. getDefaultDisplayMetrics( @Nonnull Context context)
  8. getDefaultDisplayMetrics( @Nonnull Context context)
  9. getDensity(Context context)