iAppiapp学习

iApp-v3 悬浮窗判断和拉起

2020-04-13  本文已影响0人  明日未期

添加权限

***.SYSTEM_ALERT_WINDOW

新建alert.mjava文件

import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.os.Build;
import android.provider.Settings;

//是否有悬浮窗权限
public static boolean hasAlertWindow(Activity activity){
    return Settings.canDrawOverlays(activity);
}
public static void requestAlertWindow(Activity activity){
    try {
        String packageName = activity.getPackageName();
        activity.startActivity(new Intent(Settings.ACTION_MANAGE_OVERLAY_PERMISSION, Uri.parse("package:" + packageName)));
    }catch (Exception e){}
}

iyu调用

//判断是否已开启悬浮窗
call(isOpen,"mjava","alert.hasAlertWindow",activity)
//如果没有权限可以使用这条代码,需要自己加判断
call(null,"mjava","alert.requestAlertWindow",activity)
上一篇下一篇

猜你喜欢

热点阅读