I have an app which was tested thoroughly and working fine on Android Gingerbread (and older Android versions). I’ve noticed from users’ reported crash errors that phones running later versions of the Android operating system are throwing a NetworkOnMainThreadException.
I’m trying to work through my code and eliminate/fix all culprits. Would the GeoCoder getFromLocation and getFromLocationName methods throw a NetworkOnMainThreadException if called from the main/ui thread?
Seems like these
Geocodermethods and any networking or i/o calls are going to throw up aNetworkOnMainThreadException. So, if in doubt, stick it in a separate thread!Here’s an example of how to call the
GeoCoder.getFromLocation()method from another thread: