网络主线程异常 [英] NetworkOnMainThreadException

查看:33
本文介绍了网络主线程异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚在官方文档中发现了 NetworkOnMainThreadException

I just found out about NetworkOnMainThreadException at official docs

并且想知道模拟器是否正在抛出这个.我一直在测试我的应用程序,据我所知,所有网络都在主线程之外(使用 Roboguice RoboAsyncTask),但你永远不知道是否有一个没有逃脱.

and was wondering if the emulator is throwing this. I have been testing my app quite a bit and as far as I know all networking is off the main thread (using Roboguice RoboAsyncTask) but you never know if one has not escaped.

我也在使用 StrictMode,但什么也没看到.

I am also using StrictMode and have not seen anything.

  1. 我的代码是干净的还是没有被抛出到模拟器上?

  1. Is my code just clean or is this not thrown on the emulator?

我们应该如何为生产中发生的这种情况做好准备?

How are we supposed to prepare for this happening in production?

宽限期什么的?或者现在已经过去了;-) ??

What about a grace period or something? Or is that elapsed now ;-) ??

推荐答案

我已经对此进行了测试,实际上它也发生在模拟器上.如果您打算将应用安装到 3.0 及更高版本的平板电脑上,最好确保至少在模拟器上测试您的应用.

I have tested this and it does in fact happen on the emulator as well. Better make sure you test your app at least on the emulator if you plan to get it onto the 3.0 tablets and beyond.

这篇关于网络主线程异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆