• Skip to main content
  • Skip to footer

B4X

Develop Android, iOS and IoT applications

  • Home
  • Products
    • B4A (Android)
    • B4i (iOS)
    • B4J (Desktop)
    • B4R (Arduino)
  • Showcase
  • Store
  • Learn
    • General
    • Guides
    • Video Tutorials
    • Glossary
  • Teach
  • Blog
  • Community
A B C D F G H J M N Q S T U X
Ne Nf

All

NetworkOnMainThreadException

NetworkOnMainThreadException is an exception that is thrown when an Android app tries to make any kind of network communication on the main thread.
As explained in the ANR topic, applications are expected to be responsive. Android has a special exception that is thrown whenever an app tries to make network communication on the main thread. Such problems will not happen with any of the internal libraries as the libraries use an internal pool of threads to make the communication in the background.

In most cases if you do encounter a NetworkOnMainThreadException error then it is likely that you are using a library that you shouldn’t use, assuming that the library doesn’t provide async methods as well.

In some edge cases it makes sense to disable the network on main thread check.

Note that this error will never happen in debug mode as the debugger disables this check.

Written by Erel Uziel

Footer

Top

  • Home
  • Products
    • B4A (Android)
    • B4i (iOS)
    • B4J (Desktop)
    • B4R (Arduino)
  • Showcase
  • Store
  • Learn
    • General
    • Guides
    • Video Tutorials
    • Glossary
  • Teach
  • Blog
  • Community

About us

Follow us:

Latest Versions

B4A v13.40 (changelog)
B4i v8.90 (changelog)
B4J v10.3 (changelog)
B4R v4.00 (changelog)

Contact Us

[email protected]
Privacy Policy
Accessibility Statement

Copyright © 2025 · Anywhere Software. Android is a trademark of Google Inc. iOS is a registered trademark of Apple. Arduino is a trademark of Arduino. Java is a trademark of Oracle.