add wakelock for android

This commit is contained in:
Godwin Asuquo 2022-01-21 14:32:39 +01:00
parent f021dbf6a6
commit e84f122956
2 changed files with 18 additions and 0 deletions

View file

@ -13,6 +13,7 @@ import android.os.AsyncTask;
import android.os.Build;
import android.os.Handler;
import android.os.Looper;
import android.view.WindowManager;
import com.unstoppabledomains.resolution.DomainResolution;
import com.unstoppabledomains.resolution.Resolution;
@ -39,6 +40,14 @@ public class MainActivity extends FlutterFragmentActivity {
try {
switch (call.method) {
case "enableWakeScreen":
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
handler.post(() -> result.success("screen wake turned ON"));
break;
case "disableWakeScreen":
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
handler.post(() -> result.success("screen wake turned OFF"));
break;
case "sec_random":
int count = call.argument("count");
SecureRandom random = new SecureRandom();

View file

@ -13,6 +13,7 @@ import android.os.AsyncTask;
import android.os.Build;
import android.os.Handler;
import android.os.Looper;
import android.view.WindowManager;
import com.unstoppabledomains.resolution.DomainResolution;
import com.unstoppabledomains.resolution.Resolution;
@ -39,6 +40,14 @@ public class MainActivity extends FlutterFragmentActivity {
try {
switch (call.method) {
case "enableWakeScreen":
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
handler.post(() -> result.success("screen wake turned ON"));
break;
case "disableWakeScreen":
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
handler.post(() -> result.success("screen wake turned ON"));
break;
case "sec_random":
int count = call.argument("count");
SecureRandom random = new SecureRandom();