mtpc1486
mtpc1486

Reputation: 111

Android Datagram Socket Throws "NetworkOnMainThreadException" instead of "SocketException"

In DatagramSocket reference (link to reference page), it is shown that

public void connect (SocketAddress peer)

function throws SocketException if an error occurs but in fact it may throw NetworkOnMainThreadException when the function runs on UI thread in Honeycomb or higher.

So my question is why NetworkOnMainThreadException is not written under Throws title and only SocketException is written?

Upvotes: 0

Views: 133

Answers (1)

CommonsWare
CommonsWare

Reputation: 1006759

Because SocketException is a checked exception, and NetworkOnMainThreadException is an unchecked exception.

Upvotes: 3

Related Questions