Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

添加检查悬浮窗权限辅助方法 #281

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@

import android.content.Context;
import android.content.pm.PackageManager;
import android.os.Build;
import android.provider.Settings;

import androidx.annotation.NonNull;
import androidx.core.app.NotificationManagerCompat;
Expand Down Expand Up @@ -83,7 +85,23 @@ public static boolean areNotificationsEnabled(@NonNull Context context) {
return NotificationManagerCompat.from(context).areNotificationsEnabled();
}

public static final class permission {
/**
* A helper function , Checks current app can draw on top of other apps
* Manifest.permission.SYSTEM_ALERT_WINDOW
* @param context Any context, will not be retained.
* @return Note that if Android version is lower than M, the return value will always be true.
*/
public static boolean canDrawOverlays(@NonNull Context context ){
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M){
// 对于Android 6.0(API 级别 23)及以上版本,需要检查悬浮窗权限
return Settings.canDrawOverlays(context);
}
// 在Android 6.0以下,可以认为此权限是默认授予的
return true;
}


public static final class permission {
/**
* Define the const to compat with system lower than T.
*/
Expand Down