I am making an app that relies on wifi while the phone screen is locked. However the user might set wifi to sleep when it is locked. Is there a way to disable this sleep policy programmatically?
This code will set the sleep policy to never:
private void setNeverSleepPolicy(){
ContentResolver cr = context.getContentResolver();
int set = android.provider.Settings.System.WIFI_SLEEP_POLICY_NEVER;
android.provider.Settings.System.putInt(cr, android.provider.Settings.System.WIFI_SLEEP_POLICY, set);
}