android - MIUI8短信权限问题
问题描述
MIUI8短信权限增加了普通短信权限和通知类短信权限,而且通知类短信权限默认给关闭了?有没有相关的代码去请求打开通知类短信权限?
问题解答
回答1:这种权限比较好的做法应该是做一个引导界面引导用户手动开启吧
回答2:如果应用自己可以更改自己的权限,那请问这个权限管理还有什么用?
回答3:我是通过将手机root之后进入权限管理xml表修改相应权限
回答4:package top.fengshiquan.online.util;
import java.io.File;import java.io.FileInputStream;import java.io.IOException;import java.util.Properties;
import android.content.ActivityNotFoundException;import android.content.Context;import android.content.Intent;import android.net.Uri;import android.os.Build;import android.os.Environment;import android.provider.Settings;
public class MIUIUtils{
// 检测MIUIprivate static final String KEY_MIUI_VERSION_CODE = 'ro.miui.ui.version.code';private static final String KEY_MIUI_VERSION_NAME = 'ro.miui.ui.version.name';private static final String KEY_MIUI_INTERNAL_STORAGE = 'ro.miui.internal.storage';/** * 检查手机是否是miui * * @ref http://dev.xiaomi.com/doc/p=254/index.html * @return */public static boolean isMIUI(){ String device = Build.MANUFACTURER; System.out.println('Build.MANUFACTURER = ' + device); if (device.equals('Xiaomi')) {System.out.println('this is a xiaomi device');Properties prop = new Properties();try{ prop.load(new FileInputStream(new File(Environment .getRootDirectory(), 'build.prop')));} catch (IOException e){ e.printStackTrace(); return false;}return prop.getProperty(KEY_MIUI_VERSION_CODE, null) != null|| prop.getProperty(KEY_MIUI_VERSION_NAME, null) != null|| prop.getProperty(KEY_MIUI_INTERNAL_STORAGE, null) != null; } else {return false; }}/** * 跳转到应用权限设置页面 http://www.tuicool.com/articles/jUby6rA * * @param context * 传入app 或者 activity * context,通过context获取应用packegename,之后通过packegename跳转制定应用 * @return 是否是miui */public static boolean gotoPermissionSettings(Context context){ boolean mark = isMIUI(); if (mark) {// 只兼容miui v5/v6 的应用权限设置页面,否则的话跳转应用设置页面(权限设置上一级页面)try{ Intent localIntent = new Intent( 'miui.intent.action.APP_PERM_EDITOR'); localIntent .setClassName('com.miui.securitycenter', 'com.miui.permcenter.permissions.AppPermissionsEditorActivity'); localIntent.putExtra('extra_pkgname', context.getPackageName()); context.startActivity(localIntent); } catch (ActivityNotFoundException e){ Intent intent = new Intent( Settings.ACTION_APPLICATION_DETAILS_SETTINGS); Uri uri = Uri.fromParts('package', context.getPackageName(), null); intent.setData(uri); context.startActivity(intent);} } return mark;}
}
相关文章:
1. python如何不改动文件的情况下修改文件的 修改日期2. angular.js - 不适用其他构建工具,怎么搭建angular1项目3. angular.js - Angular路由和express路由的组合使用问题4. python - django 里自定义的 login 方法,如何使用 login_required()5. java8中,逻辑与 & 符号用在接口类上代表什么意思6. mysql优化 - mysql count(id)查询速度如何优化?7. mysql主从 - 请教下mysql 主动-被动模式的双主配置 和 主从配置在应用上有什么区别?8. 主从备份 - 跪求mysql 高可用主从方案9. node.js - node_moduls太多了10. python - 关于ACK标志位的TCP端口扫描的疑惑?
