Example usage for android.provider Settings canDrawOverlays

List of usage examples for android.provider Settings canDrawOverlays

Introduction

In this page you can find the example usage for android.provider Settings canDrawOverlays.

Prototype

public static boolean canDrawOverlays(Context context) 

Source Link

Document

Checks if the specified context can draw on top of other apps.

Usage

From source file:Main.java

public static boolean checkSystemAlertWindowPer(Context context) {
    return Settings.canDrawOverlays(context);
}

From source file:Main.java

@TargetApi(Build.VERSION_CODES.M)
public static boolean canDrawOverlays(Context context) {
    return !isMarshmallowOrHigher() || Settings.canDrawOverlays(context);
}

From source file:Main.java

public static boolean canDrawOverlays(Context context) {
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M)
        return true;
    else//from  w w  w.j a  v  a 2 s  .c  om
        return Settings.canDrawOverlays(context);
}

From source file:com.achep.base.permissions.RuntimePermissions.java

/**
 * @return {@code true} if the app has this permission given,
 * {@code false} otherwise./* ww  w . j  a va 2  s.c  om*/
 */
@SuppressLint("NewApi")
public static boolean has(@NonNull Context context, @NonNull String permission) {
    switch (permission) {
    case Manifest.permission.SYSTEM_ALERT_WINDOW:
        return !Device.hasMarshmallowApi() || Settings.canDrawOverlays(context);
    case Manifest.permission.WRITE_SETTINGS:
        return !Device.hasMarshmallowApi() || Settings.System.canWrite(context);
    }

    final int r = ContextCompat.checkSelfPermission(context, permission);
    return r == PackageManager.PERMISSION_GRANTED;
}

From source file:com.hrs.filltheform.main.PermissionsManager.java

public static boolean isSystemAlertWindowPermissionEnabled(AppCompatActivity activity) {
    //noinspection SimplifiableIfStatement
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
        return Settings.canDrawOverlays(activity);
    }/*from   w w  w .  j a  v  a2s  .c o  m*/
    return true;
}

From source file:com.jarvanmo.exoplayerview.util.Permissions.java

@TargetApi(Build.VERSION_CODES.M)
public static boolean canDrawOverlays(Context context) {
    return !(Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) || Settings.canDrawOverlays(context);
}

From source file:com.acrr.base.permissions.RuntimePermissions.java

/**
 * @return {@code true} if the app has this permission given,
 * {@code false} otherwise.//from w  w  w  .jav a 2 s .  c  o  m
 * @see #allowed(Context, String)
 */
@SuppressLint("NewApi")
public static boolean has(@NonNull Context context, @NonNull String permission) {
    if (allowed(context, permission)) {
    } else
        return false;

    switch (permission) {
    case Manifest.permission.SYSTEM_ALERT_WINDOW:
        return !Device.hasMarshmallowApi() || Settings.canDrawOverlays(context);
    case Manifest.permission.WRITE_SETTINGS:
        return !Device.hasMarshmallowApi() || Settings.System.canWrite(context);
    }

    final int r = ContextCompat.checkSelfPermission(context, permission);
    return r == PackageManager.PERMISSION_GRANTED;
}

From source file:com.commonsware.android.debug.videolist.RecyclerViewActivity.java

public void setAdapter(RecyclerView.Adapter adapter) {
    boolean canDrawOverlays = (Build.VERSION.SDK_INT <= Build.VERSION_CODES.LOLLIPOP_MR1);

    if (!canDrawOverlays && Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
        canDrawOverlays = Settings.canDrawOverlays(this);
    }/*from w  w w .  j ava 2 s .co m*/

    if (BuildConfig.DEBUG && canDrawOverlays) {
        adapter = new TimingWrapper(adapter, this);
    }

    getRecyclerView().setAdapter(adapter);
}

From source file:com.example.captain_miao.grantap.utils.PermissionUtils.java

/**
 * Returns true if <code>Activity</code> or <code>Fragment</code> has access to all given permissions.
 *
 * @param context     context/*from w w w  . ja  v  a2s  .  co m*/
 * @param permissions permissions
 * @return returns true if <code>Activity</code> or <code>Fragment</code> has access to all given permissions.
 */
@TargetApi(value = Build.VERSION_CODES.M)
public static boolean hasSelfPermissions(Context context, String... permissions) {
    for (String permission : permissions) {
        if (isOverMarshmallow() && permission.equals(Manifest.permission.SYSTEM_ALERT_WINDOW)) {
            if (!Settings.canDrawOverlays(context)) {
                return false;
            }
        } else if (isOverMarshmallow() && permission.equals(Manifest.permission.WRITE_SETTINGS)) {
            if (!Settings.System.canWrite(context)) {
                return false;
            }
        } else if (PermissionChecker.checkSelfPermission(context,
                permission) != PackageManager.PERMISSION_GRANTED) {
            return false;
        }
    }
    return true;
}

From source file:com.github.yuqilin.qmediaplayerapp.util.Permissions.java

@TargetApi(Build.VERSION_CODES.M)
public static boolean canDrawOverlays(Context context) {
    return !AndroidUtil.isMarshMallowOrLater() || Settings.canDrawOverlays(context);
}