android4.0访问不能网络解决方法
2014-02-19 14:14
211 查看
@SuppressLint("NewApi")
protected void onCreate(Bundle savedInstanceState) {
StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder()
.detectDiskReads()
.detectDiskWrites()
.detectNetwork() // or .detectAll() for all detectable problems
.penaltyLog()
.build());
StrictMode.setVmPolicy(new StrictMode.VmPolicy.Builder()
.detectLeakedSqlLiteObjects()
.penaltyLog()
.penaltyDeath()
.build());
代码中加入这么一段注释, 可以在主线程访问网络, 难道以后没一个activity里面都加入? 不是很麻烦,每次都需要执行这段代码不是效率不好?
protected void onCreate(Bundle savedInstanceState) {
StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder()
.detectDiskReads()
.detectDiskWrites()
.detectNetwork() // or .detectAll() for all detectable problems
.penaltyLog()
.build());
StrictMode.setVmPolicy(new StrictMode.VmPolicy.Builder()
.detectLeakedSqlLiteObjects()
.penaltyLog()
.penaltyDeath()
.build());
代码中加入这么一段注释, 可以在主线程访问网络, 难道以后没一个activity里面都加入? 不是很麻烦,每次都需要执行这段代码不是效率不好?
相关文章推荐
- android4.0以上访问网络不能在主线程中进行以及在线程中操作UI的解决方法
- 网络邻居不能访问无法共享打印机的解决方法总结
- Android模拟器不能访问网络的解决方法
- Android4.0 主线程不能访问网络异常解决办法
- android 访问网络不能在主线程中进行以及在线程中操作UI的解决方法
- 不能访问域和内部网络的共享机器的解决方法
- 不能访问网络位置的解决方法(转)
- 不能访问网络位置的解决方法:
- Android adb 不能通过网络调试的解决方法
- 计算机无法访问,您可能没有权限使用网络资源的解决方法
- eclipse中tomcat正常启动但不能访问tomcat管理页面的解决方法
- windows7 不能连接 xp 共享打印机,不能添加网络打印机的解决方法
- apache外网不能访问分析与解决方法
- 解决Android主线程不能访问网络
- SAMBA配置 “你可能没有权限访问网络资源”的问题解决方法
- WIN 20003 共享登陆,用户名为灰色的解决方法——网络访问之开启经典模式(脚本)
- “在与 SQL Server 建立连接时出现与网络相关的或特定于实例的错误。未找到或无法访问服务器。”的解决方法
- VCenter中嵌套openstack VM不能ping通外部网络问题解决的方法
- 工作组无法访问 没有权限使用网络资源(解决方法)