I'm trying to get google pagerank on android with ADT with following code but it gives an NetworkOnMainThreadException on BufferedReader line.
String url = "http://toolbarqueries.google.com/tbr?client=navclient-auto&hl=en&"
+ "ch=6" + hash + "&ie=UTF-8&oe=UTF-8&features=Rank&q=info:" + domain;
URLConnection conn = new URL(url).openConnection();
BufferedReader br = new BufferedReader(new InputStreamReader(conn.getInputStream()));
String input;
while ((input = br.readLine()) != null) {
result = input.substring(input.lastIndexOf(":") + 1);
}
By the way I try this same code on PC java project and it works fine. I give following permission on AndroidManifest.xml too.
<uses-permission android:name="android.permission.INTERNET"></uses-permission>