I wanted to learn twitter connect example. For that i just downloaded a sample app from here. I just tried to run that app. When I run this app on Android 2.3.3, it is working fine but when I run it on android 4.1.2, it’s giving an error NetworkOnMainThreadException. In that code, the author has used AsynTask background thread to perform network operations but still this error exists. Now I am confused, where is the error coming from. Please help.
I wanted to learn twitter connect example. For that i just downloaded a sample
Share
There are two Solution of this Problem.
1) Don’t write network call in Main
UIThread, UseAsyncTask for that.2) Write below code into your
MainActivityfile aftersetContentView(R.layout.activity_main);And below import statement into your java file.