Reputation: 313
I'm trying to reach internet through my Android app, but I both succeed and fail.
I start the emulator when I build my app, and the app is installed just fine. I can use the browser to access the internet, however, when I try this small code snippet ...
InetAddress inet;
try {
inet = InetAddress.getByName("www.google.com");
System.out.println ("IP : " + inet.getHostAddress());
} catch (UnknownHostException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
... it all fails.
Is there any setting you must do to make the app reach the internet?
Upvotes: 2
Views: 1145
Reputation: 7486
You must add this to your manifest file:
<uses-permission android:name="android.permission.INTERNET" />
to demand authorization to access internet from your app
Upvotes: 1