android当前apn的状态以及获取方法
16lz
2021-01-26
在绝大多数android机器etc路径下存放一个的apns-conf.xml文件,表示当前机器使用的apn信息通过root机器可以push出来看看,具体路径可以上网搜下
复制代码 代码如下:
static Uri PREFERRED_APN_URI = Uri.parse("content://telephony/carriers/preferapn");
ContentResolver cResolver = context.getContentResolver();
Cursor cr = cResolver.query(PREFERRED_APN_URI, null, null, null, null);
cr.moveToFirst();
String user = cr.getString(cr.getColumnIndex("user"));
String pass = cr.getString(cr.getColumnIndex("password"));
//然后对获取的用户名和密码做相关处理获取对应的apn状态
复制代码 代码如下:
static Uri PREFERRED_APN_URI = Uri.parse("content://telephony/carriers/preferapn");
ContentResolver cResolver = context.getContentResolver();
Cursor cr = cResolver.query(PREFERRED_APN_URI, null, null, null, null);
cr.moveToFirst();
String user = cr.getString(cr.getColumnIndex("user"));
String pass = cr.getString(cr.getColumnIndex("password"));
//然后对获取的用户名和密码做相关处理获取对应的apn状态
更多相关文章
- 【Android】新浪微博开放平台V2开发入门基础
- Android获取应用运行次数
- 关于Studio和EclipseSHA1值的查看
- Android 获取手机IMEI 和 IMSI 号
- Android(安卓)studio 获取手机联系人和号码并输出
- webView获取链接后的url和加载经过处理后的HTML
- android 标题栏的高度
- android自动化之MonkeyRunner测试环境配置(一)
- (持续更新, 目前含100+工具类) DevUtils 是一个 Android(安卓)工