Example usage for android.app AppOpsManager OPSTR_SYSTEM_ALERT_WINDOW

List of usage examples for android.app AppOpsManager OPSTR_SYSTEM_ALERT_WINDOW

Introduction

In this page you can find the example usage for android.app AppOpsManager OPSTR_SYSTEM_ALERT_WINDOW.

Prototype

String OPSTR_SYSTEM_ALERT_WINDOW

To view the source code for android.app AppOpsManager OPSTR_SYSTEM_ALERT_WINDOW.

Click Source Link

Document

Required to draw on top of other apps.

Usage

From source file:Main.java

@SuppressWarnings("IncompatibleBitwiseMaskOperation")
public static boolean isFloatWindowOpAllowed(Context context) {
    if (Build.VERSION.SDK_INT >= 19) { // 19, 4.4, KITKAT
        final AppOpsManager manager = (AppOpsManager) context.getSystemService(Context.APP_OPS_SERVICE);
        final int mode = manager.checkOp(AppOpsManager.OPSTR_SYSTEM_ALERT_WINDOW, Binder.getCallingUid(),
                context.getPackageName());
        return AppOpsManager.MODE_ALLOWED == mode;
    } else {//  w  w  w .  j a va2  s .  c  om
        return (context.getApplicationInfo().flags & 1 << 27) == 1;
    }
}