package com.mxn.helper.screenshot.utils;

import android.content.Context;
import android.net.wifi.WifiInfo;
import android.net.wifi.WifiManager;

public class WifiUtils {

    /**
     * 获取当前连接的Wi-Fi名称
     * @param context 上下文对象
     * @return 当前连接的Wi-Fi名称，如果未连接返回null
     */
    public static String getConnectedWifiName(Context context) {
        WifiManager wifiManager = (WifiManager) context.getApplicationContext().getSystemService(Context.WIFI_SERVICE);
        WifiInfo wifiInfo = wifiManager.getConnectionInfo();
        if (wifiInfo != null && wifiInfo.getSSID() != null) {
            return wifiInfo.getSSID().replace("\"", "");
        }
        return null;
    }
}
