Android:No permission to write APN settings(沒有写入 APN 设置的权限)

news/2024/7/7 19:56:17

如果你想读Android 4.2以及以上版本的APN,我觉得你改变一下方法即可。我试了,而且可以实现。

在Android 4.1 以及以下版本 :

Cursor c = getContentResolver().query(Uri.withAppendedPath(Telephony.Carriers.CONTENT_URI, "current"), null, null, null, null);


在Android 4.2 以及以上版本:

private static final String[] APN_PROJECTION = {
     Telephony.Carriers.TYPE,            // 0
     Telephony.Carriers.MMSC,            // 1
     Telephony.Carriers.MMSPROXY,        // 2
     Telephony.Carriers.MMSPORT          // 3
 };
并且加上这一句:

final Cursor apnCursor =SqliteWrapper.query(context, this.context.getContentResolver(), Uri.withAppendedPath(Carriers.CONTENT_URI, "current"), APN_PROJECTION, null, null, null);


注释: SQLiteWrapperClass 是隐藏的 (在网上发现的这个类)
在开头写一句导入语句:

import android.database.sqlite.SqliteWrapper;


转载地址:http://stackoverflow.com/questions/13453640/read-apns-in-android-4-2



http://www.niftyadmin.cn/n/3648896.html

相关文章

自定义view之实现文字不同颜色

效果图 定义属性 <declare-styleable name"ColorTrackTextView"><attr name"originColor" format"color"/><attr name"changeColor" format"color"/></declare-styleable> 自定义布局&#x…

[Regex]ASP.NET 中的正则表达式-微软速成课程

ASP.NET 中的正则表达式发布日期&#xff1a; 8/17/2004| 更新日期&#xff1a; 8/17/2004速成课程Steven A. Smith适用范围&#xff1a;Microsoft .NET FrameworkMicrosoft ASP.NET正则表达式 API摘要&#xff1a;正则表达式是一种处理文本的有用工具。无论是验证用户输入、搜…

debian交叉编译ide_如何在Debian 10上设置Eclipse Theia Cloud IDE平台

debian交叉编译ide介绍 (Introduction) With developer tools moving to the cloud, adoption of cloud IDE (Integrated Development Environment) platforms is growing. Cloud IDEs are accessible from every type of modern device through web browsers, and they offer …

Android获取手机型号,系统版本,App版本号等信息

MainActivity如下: package cn.testgethandsetinfo; import android.os.Bundle; import android.text.TextUtils; import android.widget.TextView; import android.app.Activity; import android.content.Context; import android.content.pm.PackageInfo; import android.co…

如何在Ubuntu 18.04上使用PHP在MySQL中实现分页

The author selected the the Apache Software Foundation to receive a donation as part of the Write for DOnations program. 作者选择了Apache软件基金会作为Write for DOnations计划的一部分来接受捐赠。 介绍 (Introduction) Pagination is the concept of constrainin…

自定义view——仿支付宝咻一咻

效果图 这里首先我们我们做一个波波&#xff0c;思路是这样&#xff1a;①设置圆圈的画笔②绘制图片到中心位置&#xff0c;并设置波的大小为图片宽度的一半③hanlder中设置波的半径不断变大&#xff0c;当半径大于画布宽度一半的时候设置半径为图片的宽度一半 public class X…

Android 5.0 权限管理导致的apk安装失败解决方案

在刚5.0出来的时候&#xff0c; 很多apk 在 5.0上会安装失败&#xff0c; 原因其实是&#xff0c; 安装的apk 中的 自定义权限 与 手机上面已经有的app 的自定义权限相同。 问题&#xff1a;当初有做 百度地图的同事就遇到了这个问题&#xff0c; app一直安装失败。需要去掉权限…

如何在CentOS 7上设置Eclipse Theia Cloud IDE平台

介绍 (Introduction) With developer tools moving to the cloud, adoption of cloud IDE (Integrated Development Environment) platforms is growing. Cloud IDEs are accessible from every type of modern device through web browsers, and they offer numerous advantag…