更改联想PAD启动小智语音的时机
This commit is contained in:
@@ -0,0 +1,59 @@
|
||||
package com.mogo.utils.permissions;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.AlertDialog;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.provider.Settings;
|
||||
import android.text.TextUtils;
|
||||
|
||||
/**
|
||||
* @author xiaoyuzhou
|
||||
* @date 2021/7/22 4:57 下午
|
||||
*/
|
||||
public class PermissionsDialogUtils {
|
||||
|
||||
public static AlertDialog mAlertDialog;
|
||||
|
||||
|
||||
/**
|
||||
* 打开APP的详情设置
|
||||
*/
|
||||
public static void openAppDetails(Activity activity, String msg, int CODE_WINDOW) {
|
||||
if (mAlertDialog == null || !mAlertDialog.isShowing()) {
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(activity);
|
||||
if (TextUtils.isEmpty(msg)) {
|
||||
builder.setMessage("请在 “应用信息 -> 权限” 中授予权限");
|
||||
} else {
|
||||
builder.setMessage("请在 “应用信息 -> 权限” 中授予【" + msg + "】权限");
|
||||
}
|
||||
builder.setPositiveButton("手动授权", (dialog, which) -> {
|
||||
Intent intent = new Intent();
|
||||
intent.setAction(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
|
||||
intent.addCategory(Intent.CATEGORY_DEFAULT);
|
||||
intent.setData(Uri.parse("package:" + activity.getPackageName()));
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
|
||||
activity.startActivityForResult(intent, CODE_WINDOW);
|
||||
});
|
||||
builder.setCancelable(false);
|
||||
mAlertDialog = builder.show();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 跳转浮层权限获取页面
|
||||
*
|
||||
* @param activity
|
||||
* @param CODE_WINDOW
|
||||
*/
|
||||
public static void openOverlayPermission(Activity activity, int CODE_WINDOW) {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
activity.startActivityForResult(new Intent(Settings.ACTION_MANAGE_OVERLAY_PERMISSION,
|
||||
Uri.parse("package:" + activity.getPackageName())), CODE_WINDOW);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user