Reading Connected Hotspot Information in Android 13 Applications
Required Permissions
To access hotspot informatoin, declare the following permissions in your AndroidManifest.xml file:
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
Detecting Hotspot Conenction Status
Initialize a WifiManager instance to check if the device is connected to a hotspot:
WifiManager networkManager = (WifiManager) getApplicationContext().getSystemService(Context.WIFI_SERVICE);
if (networkManager.isWifiApEnabled()) {
// Device is connected to a hotspot
} else {
// Device is not connected to a hotspot
}
Retrieving Hotspot Details
Once a hotspot connection is confirmed, obtain detailed information about the connectoin:
WifiInfo connectionDetails = networkManager.getConnectionInfo();
String networkSSID = connectionDetails.getSSID();
int signalStrength = connectionDetails.getRssi();