简体   繁体   中英

Why am I getting an NetworkOnMainThreadException?

When I make a service call from my Android activity, I see an android.os.NetworkOnMainThreadException . Why?

You should perform any service call from a background thread. On the UI (or main) thread, you are not allowed to do such a time-consuming operation. For example, see the AsyncTask documentation and usage .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM