Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//License from project: Open Source License 

import android.content.Context;

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

public class Main {
    private static final String SOLO_LINK_WIFI_PREFIX = "SoloLink_";

    public static boolean isOnSoloNetwork(Context context) {
        if (context == null) {
            return false;
        }

        final String connectedSSID = getCurrentWifiLink(context);
        return connectedSSID != null && connectedSSID.startsWith(SOLO_LINK_WIFI_PREFIX);
    }

    public static String getCurrentWifiLink(Context context) {
        if (context == null)
            return null;

        final WifiManager wifiMgr = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);

        final WifiInfo connectedWifi = wifiMgr.getConnectionInfo();
        final String connectedSSID = connectedWifi == null ? null : connectedWifi.getSSID().replace("\"", "");
        return connectedSSID;
    }
}