Auto Detect a specific wifi connection and start app

hello am developing a hotel app and I want my app to work only within the hotel. To do this I am checking if the user is currently connected to the hotel’s specific wifi before initiating the home activity. By now I am able to check if the connection is wifi and its cool the only part am missing is how to check if the connected wifi is the one provided by the hotel. Any idea here please?

most questions that am finding about this have not yet been answered and some answeres date back to 2013 which may not be very appropriate for me.

Answer

try this.

 private void checkWifiConnection() {

    ConnectivityManager connMgr = (ConnectivityManager) c.getSystemService(Context.CONNECTIVITY_SERVICE);
    NetworkInfo netwifi = connMgr.getNetworkInfo(ConnectivityManager.TYPE_WIFI);
    if (netwifi.getState() == NetworkInfo.State.CONNECTED) {
        WifiInfo info = wifi.getConnectionInfo();
        String ssid = info.getSSID();
        if (ssid.equals("your SSID here")) {
            Toast.makeText(this, "Connected to :" + ssid, Toast.LENGTH_SHORT).show();
        } else {
                 //If not then do nothing.
        }
    }
}