January 16, 2015

android.os.NetworkOnMainThreadException

android.os.NetworkOnMainThreadException  is an android runtime exception which occurs when you are trying to run any network or IO related operations from main activity. Android doesn't support to run IO operations directly on the main activity. 

So to avoid this exception, use a thread to do these operations or you can also use AsyncTask class which helps you to run the code in the background.

2 comments:

  1. Android 5.1 isn't one of those massive life-changing releases that'll have you tapping the 'look for updates' button frenetically for days on end. To know more, Visit Android training in Bangalore

    ReplyDelete
  2. Android lollilop is the best versions in android. we are one of the best android training institute in chennai. our training adapts to the latest version of android.

    ReplyDelete