Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//License from project: Apache License 

import android.app.AppOpsManager;
import android.content.Context;

import android.os.Binder;
import android.os.Build;

public class Main {
    @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 {
            return (context.getApplicationInfo().flags & 1 << 27) == 1;
        }
    }
}