There are some other operations that jelly bean, ICS, HoneyComb won't allow to perform on the UI thread like:
- HTTP requests (i.e. HTTPClient and HTTPUrlConnection).
- Opening a Socket connection (i.e. new Socket()).
- Attempting to connect to a remote MySQL database.
- Downloading a file (i.e. Downloader.downloadFile()).
Solution:
There are three ways to solve the problem of NetworkOnMainThreadException.
- If you look at android document you will find that from Honeycomb (3.0) they have introduced StrictMode which will not allow network operations on UI thread. So one simple solution is disabling the StrictMode.
StrictMode.setThreadPolicy(policy);
But I will not recommend this solution as it will increase load on UI thread with expensive operations like network operation which may freeze your app's UI and freezing UI or lagging in UI will give bad user experience.
- Second solution is to use AsyncTask<Params, Progress, Result> , using async task you can do all the long running operations which may result in UI lagging if you do those operations on UI thread.
- Third solution is to use Service. for network operations. Where you required to download data once only when user starts the app in that case I recommend IntentService.
Hi Suru,
ReplyDeleteThanks a lot, this is really useful information.
This blog is the general information for the feature. You got a good work for these blog.We have a developing our creative content of this mind.Thank you for this blog. This for very interesting and useful.
ReplyDeleterpa Training in Chennai
rpa Training in bangalore
rpa Training in pune
blueprism Training in Chennai
blueprism Training in bangalore
blueprism Training in pune
iot-training-in-chennai
A universal message I suppose, not giving up is the formula for success I think. Some things take longer than others to accomplish, so people must understand that they should have their eyes on the goal, and that should keep them motivated to see it out til the end.
ReplyDeleteData Science training in marathahalli
Data Science training in btm
Data Science training in rajaji nagar
Data Science training in chennai
Data Science training in electronic city
Data Science training in USA
Data science training in pune
Data science training in kalyan nagar
I love the blog. Great post. It is very true, people must learn how to learn before they can learn. lol i know it sounds funny but its very true. . .
ReplyDeletepython online training
python training in OMR
python training in tambaram
I recently came across your blog and have been reading along. I thought I would leave my first comment.
ReplyDeleteBlueprism online training
Blue Prism Training in Pune
This is such a great post, and was thinking much the same myself. Another great update.
ReplyDeleteangularjs-Training in chennai
angularjs Training in chennai
angularjs-Training in tambaram
angularjs-Training in sholinganallur
angularjs-Training in velachery
I would assume that we use more than the eyes to gauge a person's feelings. Mouth. Body language. Even voice. You could at least have given us a face in this test.
ReplyDeleteangularjs Training in chennai
angularjs-Training in pune
angularjs-Training in chennai
angularjs Training in chennai
angularjs-Training in tambaram
I know you feel more happy when you get things done and best of all those things are your most precious treasure.
ReplyDeleteangularjs Training in bangalore
angularjs Training in btm
angularjs Training in electronic-city
angularjs online Training
angularjs Training in marathahalli
I have picked cheery a lot of useful clothes outdated of this amazing blog. I’d love to return greater than and over again. Thanks!
ReplyDeleteangularjs Training in chennai
angularjs-Training in pune
angularjs-Training in chennai
angularjs Training in chennai
angularjs-Training in tambaram
Good Post, I am a big believer in posting comments on sites to let the blog writers know that they ve added something advantageous to the world wide web.
ReplyDeleteangularjs Training in chennai
angularjs-Training in pune
angularjs-Training in chennai
angularjs Training in chennai
angularjs-Training in tambaram
Hmm, it seems like your site ate my first comment (it was extremely long) so I guess I’ll just sum it up what I had written and say, I’m thoroughly enjoying your blog. I as well as an aspiring blog writer, but I’m still new to the whole thing. Do you have any recommendations for newbie blog writers? I’d appreciate it.
ReplyDeleteAWS Interview Questions And Answers
AWS Training in Bangalore | Amazon Web Services Training in Bangalore
AWS Training in Pune | Best Amazon Web Services Training in Pune
Amazon Web Services Training in Pune | Best AWS Training in Pune
thanks for sharing this information
ReplyDeleteAmazon web services training in bangalore
best AWS Training institute in Bangalore
best training institute for data science in bangalore
best tableau training institutes in bangalore
best python training institute in bangalore
python training in jayanagar bangalore
Artificial Intelligence training in Bangalore
Que
ReplyDeleteMmorpg oyunlar
ReplyDeleteINSTAGRAM TAKİPÇİ SATIN AL
TİKTOK JETON HİLESİ
tiktok jeton hilesi
antalya saç ekim
referans kimliği nedir
instagram takipçi satın al
metin2 pvp serverlar
İNSTAGRAM TAKİPÇİ
minecraft premium
ReplyDeleteuc satın al
yurtdışı kargo
özel ambulans
en son çıkan perde modelleri
nft nasıl alınır
en son çıkan perde modelleri
lisans satın al