NetworkOnMainThreadException [英] NetworkOnMainThreadException

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

问题描述

我刚刚发现了关于<一个href="http://developer.android.com/reference/android/os/NetworkOnMainThreadException.html">NetworkOnMainThreadException在官方的文档

和在想,如果仿真器引发此。我一直在测试我的应用程序颇有几分而据我所知,所有的网络处于关闭状态(使用Roboguice RoboAsyncTask)主线程,但你永远不知道,如果一个也没有逃脱。

我还使用StrictMode并没有看到任何东西。

  1. 是我的code刚干净或这是不是扔在模拟器上?

  2. 我们怎么到prepare对于这种情况发生在生产?

  3. 怎么样一个宽限期什么? 或者是说过去,现在;-)?

解决方案

我已经测试了这一点,它实际上是发生在模拟器上也是如此。最好确保你至少在模拟器上测试您的应用程序,如果你打算把它到3.0平板电脑和超越。

I just found out about NetworkOnMainThreadException at official docs

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.

I am also using StrictMode and have not seen anything.

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

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

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

解决方案

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.

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

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