NetworkOnMainThreadException

简介: 引起问题的 部分   加入线程中运行 new Thread(new Runnable() { @Override public void run() { // TODO Auto-generated method stub } }).start(); NetworkOnMainThreadException 02-2


引起问题的 部分   加入线程中运行

new Thread(new Runnable() {

			@Override
			public void run() {
				// TODO Auto-generated method stub
				 
			}
		}).start();






NetworkOnMainThreadException

02-25 14:50:57.420: E/AndroidRuntime(16377): android.os.NetworkOnMainThreadException
02-25 14:50:57.420: E/AndroidRuntime(16377): at android.os.StrictMode$AndroidBlockGuardPolicy.onNetwork(StrictMode.java:1128)
02-25 14:50:57.420: E/AndroidRuntime(16377): at java.net.InetAddress.lookupHostByName(InetAddress.java:385)
02-25 14:50:57.420: E/AndroidRuntime(16377): at java.net.InetAddress.getAllByNameImpl(InetAddress.java:236)
02-25 14:50:57.420: E/AndroidRuntime(16377): at java.net.InetAddress.getAllByName(InetAddress.java:214)
02-25 14:50:57.420: E/AndroidRuntime(16377): at libcore.net.http.HttpConnection.<init>(HttpConnection.java:70)
02-25 14:50:57.420: E/AndroidRuntime(16377): at libcore.net.http.HttpConnection.<init>(HttpConnection.java:50)
02-25 14:50:57.420: E/AndroidRuntime(16377): at libcore.net.http.HttpConnection$Address.connect(HttpConnection.java:340)
02-25 14:50:57.420: E/AndroidRuntime(16377): at libcore.net.http.HttpConnectionPool.get(HttpConnectionPool.java:87)
02-25 14:50:57.420: E/AndroidRuntime(16377): at libcore.net.http.HttpConnection.connect(HttpConnection.java:128)
02-25 14:50:57.420: E/AndroidRuntime(16377): at libcore.net.http.HttpEngine.openSocketConnection(HttpEngine.java:315)
02-25 14:50:57.420: E/AndroidRuntime(16377): at libcore.net.http.HttpEngine.connect(HttpEngine.java:310)
02-25 14:50:57.420: E/AndroidRuntime(16377): at libcore.net.http.HttpEngine.sendSocketRequest(HttpEngine.java:289)
02-25 14:50:57.420: E/AndroidRuntime(16377): at libcore.net.http.HttpEngine.sendRequest(HttpEngine.java:239)
02-25 14:50:57.420: E/AndroidRuntime(16377): at libcore.net.http.HttpURLConnectionImpl.connect(HttpURLConnectionImpl.java:80)
02-25 14:50:57.420: E/AndroidRuntime(16377): at java.net.URLConnection.getContent(URLConnection.java:190)
02-25 14:50:57.420: E/AndroidRuntime(16377): at java.net.URL.getContent(URL.java:447)
02-25 14:50:57.420: E/AndroidRuntime(16377): at com.huashang.huishang.utils.AsynImageLoader.loadImageFromUrl(AsynImageLoader.java:62)
02-25 14:50:57.420: E/AndroidRuntime(16377): at com.huashang.huishang.activity.adapter.PageMessageListAdapter.getView(PageMessageListAdapter.java:97)
02-25 14:50:57.420: E/AndroidRuntime(16377): at android.widget.AbsListView.obtainView(AbsListView.java:2429)
02-25 14:50:57.420: E/AndroidRuntime(16377): at android.widget.ListView.makeAndAddView(ListView.java:1769)
02-25 14:50:57.420: E/AndroidRuntime(16377): at android.widget.ListView.fillDown(ListView.java:672)
02-25 14:50:57.420: E/AndroidRuntime(16377): at android.widget.ListView.fillFromTop(ListView.java:733)
02-25 14:50:57.420: E/AndroidRuntime(16377): at android.widget.ListView.layoutChildren(ListView.java:1608)
02-25 14:50:57.420: E/AndroidRuntime(16377): at android.widget.AbsListView.onLayout(AbsListView.java:2264)
02-25 14:50:57.420: E/AndroidRuntime(16377): at android.view.View.layout(View.java:13873)
02-25 14:50:57.420: E/AndroidRuntime(16377): at android.view.ViewGroup.layout(ViewGroup.java:4500)
02-25 14:50:57.420: E/AndroidRuntime(16377): at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1649)
02-25 14:50:57.420: E/AndroidRuntime(16377): at android.widget.LinearLayout.layoutHorizontal(LinearLayout.java:1638)
02-25 14:50:57.420: E/AndroidRuntime(16377): at android.widget.LinearLayout.onLayout(LinearLayout.java:1422)
02-25 14:50:57.420: E/AndroidRuntime(16377): at android.view.View.layout(View.java:13873)
02-25 14:50:57.420: E/AndroidRuntime(16377): at android.view.ViewGroup.layout(ViewGroup.java:4500)
02-25 14:50:57.420: E/AndroidRuntime(16377): at android.widget.FrameLayout.onLayout(FrameLayout.java:448)
02-25 14:50:57.420: E/AndroidRuntime(16377): at android.view.View.layout(View.java:13873)
02-25 14:50:57.420: E/AndroidRuntime(16377): at android.view.ViewGroup.layout(ViewGroup.java:4500)
02-25 14:50:57.420: E/AndroidRuntime(16377): at android.widget.FrameLayout.onLayout(FrameLayout.java:448)
02-25 14:50:57.420: E/AndroidRuntime(16377): at android.view.View.layout(View.java:13873)
02-25 14:50:57.420: E/AndroidRuntime(16377): at android.view.ViewGroup.layout(ViewGroup.java:4500)
02-25 14:50:57.420: E/AndroidRuntime(16377): at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1649)
02-25 14:50:57.420: E/AndroidRuntime(16377): at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1507)
02-25 14:50:57.420: E/AndroidRuntime(16377): at android.widget.LinearLayout.onLayout(LinearLayout.java:1420)
02-25 14:50:57.420: E/AndroidRuntime(16377): at android.view.View.layout(View.java:13873)
02-25 14:50:57.420: E/AndroidRuntime(16377): at android.view.ViewGroup.layout(ViewGroup.java:4500)
02-25 14:50:57.420: E/AndroidRuntime(16377): at android.widget.FrameLayout.onLayout(FrameLayout.java:448)
02-25 14:50:57.420: E/AndroidRuntime(16377): at android.view.View.layout(View.java:13873)
02-25 14:50:57.420: E/AndroidRuntime(16377): at android.view.ViewGroup.layout(ViewGroup.java:4500)
02-25 14:50:57.420: E/AndroidRuntime(16377): at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1649)
02-25 14:50:57.420: E/AndroidRuntime(16377): at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1507)
02-25 14:50:57.420: E/AndroidRuntime(16377): at android.widget.LinearLayout.onLayout(LinearLayout.java:1420)
02-25 14:50:57.420: E/AndroidRuntime(16377): at android.view.View.layout(View.java:13873)
02-25 14:50:57.420: E/AndroidRuntime(16377): at android.view.ViewGroup.layout(ViewGroup.java:4500)
02-25 14:50:57.420: E/AndroidRuntime(16377): at android.widget.FrameLayout.onLayout(FrameLayout.java:448)
02-25 14:50:57.420: E/AndroidRuntime(16377): at android.view.View.layout(View.java:13873)
02-25 14:50:57.420: E/AndroidRuntime(16377): at android.view.ViewGroup.layout(ViewGroup.java:4500)
02-25 14:50:57.420: E/AndroidRuntime(16377): at android.view.ViewRootImpl.performLayout(ViewRootImpl.java:1941)
02-25 14:50:57.420: E/AndroidRuntime(16377): at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1762)
02-25 14:50:57.420: E/AndroidRuntime(16377): at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1072)
02-25 14:50:57.420: E/AndroidRuntime(16377): at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:4297)
02-25 14:50:57.420: E/AndroidRuntime(16377): at android.view.Choreographer$CallbackRecord.run(Choreographer.java:725)
02-25 14:50:57.420: E/AndroidRuntime(16377): at android.view.Choreographer.doCallbacks(Choreographer.java:555)
02-25 14:50:57.420: E/AndroidRuntime(16377): at android.view.Choreographer.doFrame(Choreographer.java:525)
02-25 14:50:57.420: E/AndroidRuntime(16377): at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:711)
02-25 14:50:57.420: E/AndroidRuntime(16377): at android.os.Handler.handleCallback(Handler.java:615)
02-25 14:50:57.420: E/AndroidRuntime(16377): at android.os.Handler.dispatchMessage(Handler.jav

目录
相关文章
|
编解码 Java 编译器
深入剖析Android四大组件(三)——AIDL实现Android IPC
深入剖析Android四大组件(三)——AIDL实现Android IPC
170 0
深入剖析Android四大组件(三)——AIDL实现Android IPC
|
数据库
读取数据库的照片和视频报android.os.NetworkOnMainThreadException
读取数据库的照片和视频报android.os.NetworkOnMainThreadException
80 0
读取数据库的照片和视频报android.os.NetworkOnMainThreadException
|
Android开发 安全 消息中间件
Android中的异步处理技术之HandlerThread
目录 前言 众所周知如果想要在Android中执行耗时操作需要新建一个线程然后在该线程中实现,但是如果出现一种需要我们频繁进行耗时操作的业务,那我们再频繁的创建线程无疑会使性能降低,而Android SDK为我们提供了一个循环线程的框架刚好可以帮助我们解决这个问题,它就是HandlerThread。
1195 0
|
消息中间件 Android开发
Caused by: android.os.NetworkOnMainThreadException
问题: Caused by: android.os.NetworkOnMainThreadException at android.os.StrictMode$AndroidBlockGuardPolicy.
2090 0