diff --git a/app/src/main/java/com/github/uiautomator/ToastActivity.java b/app/src/main/java/com/github/uiautomator/ToastActivity.java index 04e71fc..562b328 100644 --- a/app/src/main/java/com/github/uiautomator/ToastActivity.java +++ b/app/src/main/java/com/github/uiautomator/ToastActivity.java @@ -29,17 +29,16 @@ protected void onCreate(@Nullable Bundle savedInstanceState) { String showFloat = intent.getStringExtra("showFloatWindow"); Log.i(TAG, "showFloat: " + showFloat); - boolean floatEnabled = FloatWindowManager.getInstance().checkFloatPermission(ToastActivity.this); + boolean floatEnabled = FloatWindowManager.getInstance().checkPermission(ToastActivity.this); if (!floatEnabled) { Log.w(TAG, "floatPermission is not enabled"); - return; + } else { + if ("true".equals(showFloat)) { + getFloatView().show(); + } else if ("false".equals(showFloat)) { + getFloatView().hide(); + } } - if ("true".equals(showFloat)) { - getFloatView().show(); - } else if ("false".equals(showFloat)) { - getFloatView().hide(); - } - moveTaskToBack(true); } diff --git a/permission/src/main/java/com/android/permission/FloatWindowManager.java b/permission/src/main/java/com/android/permission/FloatWindowManager.java index 8456e37..ac1c146 100644 --- a/permission/src/main/java/com/android/permission/FloatWindowManager.java +++ b/permission/src/main/java/com/android/permission/FloatWindowManager.java @@ -62,7 +62,7 @@ public boolean checkFloatPermission(Context context) { } } - private boolean checkPermission(Context context) { + public boolean checkPermission(Context context) { //6.0 版本之后由于 google 增加了对悬浮窗权限的管理,所以方式就统一了 if (Build.VERSION.SDK_INT < 23) { if (RomUtils.checkIsMiuiRom()) {