博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Android 2.2 及2.2以下关闭 3G上网
阅读量:7309 次
发布时间:2019-06-30

本文共 1039 字,大约阅读时间需要 3 分钟。

hot3.png

Method dataConnSwitchmethod;Class telephonyManagerClass;Object ITelephonyStub;Class ITelephonyClass;TelephonyManager telephonyManager = (TelephonyManager) context        .getSystemService(Context.TELEPHONY_SERVICE);if(telephonyManager.getDataState() == TelephonyManager.DATA_CONNECTED){    isEnabled = true;}else{    isEnabled = false;  }   telephonyManagerClass = Class.forName(telephonyManager.getClass().getName());Method getITelephonyMethod = telephonyManagerClass.getDeclaredMethod("getITelephony");getITelephonyMethod.setAccessible(true);ITelephonyStub = getITelephonyMethod.invoke(telephonyManager);ITelephonyClass = Class.forName(ITelephonyStub.getClass().getName());if (isEnabled) {    dataConnSwitchmethod = ITelephonyClass            .getDeclaredMethod("disableDataConnectivity");} else {    dataConnSwitchmethod = ITelephonyClass            .getDeclaredMethod("enableDataConnectivity");   }dataConnSwitchmethod.setAccessible(true);dataConnSwitchmethod.invoke(ITelephonyStub);

转载于:https://my.oschina.net/netmouse/blog/186102

你可能感兴趣的文章
SAP CRM系统订单模型的设计与实现
查看>>
${value}
查看>>
hdfs写流程
查看>>
手把手指导您使用 Git
查看>>
IDEA快捷键(待续)
查看>>
Java 内存模型
查看>>
区块链-3:区块链底层架构
查看>>
说一说 Spring AOP 中 @Aspect 的高级用法
查看>>
springboot 统一异常处理(包含统一数据校验)
查看>>
Node.js 工具模块
查看>>
闲得无聊?不如用Python设计一个经典小游戏
查看>>
50年以后人工智能将会超越人类大脑,机器控制人类已经成为可能!
查看>>
svnmanager若干bug与漏洞处理
查看>>
一些技术点在其它博客里面的详解
查看>>
MySQL-5.7.18
查看>>
OSChina 周三乱弹 ——程序员祭天传统的真相!
查看>>
OSChina 周日乱弹 ——颜值和代码水平是正比
查看>>
mingw下编译pycrypto出现-mno-cygwin错误
查看>>
NIO非阻塞网络IO-TCP
查看>>
PyConChina2015 大会简介
查看>>