Created
June 8, 2016 19:19
-
-
Save talhahasanzia/e80840f739ade867792729078ca664a9 to your computer and use it in GitHub Desktop.
Change volume of the phone when connected to a specific wifi
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class WifiTest | |
{ | |
// ringerMode = AudioManager.RINGER_MODE_SILENT; | |
// ringerMode = AudioManager.RINGER_MODE_VIBRATE; | |
// ringerMode = AudioManager.RINGER_MODE_NORMAL; | |
// WifiName="Home-Wifi"; | |
public static boolean setVolumeWhenThisWifiConnects(String WifiName,int ringerMode) | |
{ | |
WifiManager wifiManager = (WifiManager) getSystemService(Context.WIFI_SERVICE); | |
WifiInfo connectionInfo = wifiManager.getConnectionInfo(); | |
if (connectionInfo != null && !StringUtil.isBlank(connectionInfo.getSSID())) { | |
if(connectionInfo.getSSID()==WifiName) | |
{ | |
AudioManager myAudioManager; | |
myAudioManager = (AudioManager)getSystemService(Context.AUDIO_SERVICE); | |
// set silent mode | |
myAudioManager.setRingerMode(AudioManager.RINGER_MODE_SILENT); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment