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. java - ehcache缓存用的是虚拟机内存么?2. javascript - node中Promise也被嵌套了3. node.js - nodejs中mysql子查询返回多行结果怎么处理?4. css3里rotate怎么实现如图的效果5. css - 网页宽高固定且大于浏览器(react)6. 用Java8的 stream 操作外部集合是否存在并发问题?7. lambda - java8 一个对象按照对象里的某一个字段的顺序排列8. javascript - 写移动端的页面的时候,有不一快空白,是怎么回事?9. CSS属性中的`auto`值是什么意思10. 如何解决iphone5手机搜狗输入法获取焦点遮挡输入框的问题