java - HttpClient.execute always gives Exception -
i tried bring html of web , use code doing :
httpclient httpclient = new defaulthttpclient(); httpcontext localcontext = new basichttpcontext(); httpget httpget = new httpget("http://www.google.com"); httpresponse response; try { response = httpclient.execute(httpget, localcontext); } catch (clientprotocolexception e) { // todo auto-generated catch block e.printstacktrace(); } catch (ioexception e) { // todo auto-generated catch block e.printstacktrace(); }
and in response = httpclient.execute(httpget, localcontext);
give me exception, in other codes tried
have tried setting internet
permission in manifest file?
sample code:
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="sample.hello" android:versioncode="1" android:versionname="1.0"> <!--- here put permissions. ---> <uses-permission android:name="android.permission.internet" /> <application android:icon="@drawable/icon" android:label="@string/app_name"> <activity android:name=".helloworld" android:label="@string/app_name"> <intent-filter> <action android:name="android.intent.action.main" /> <category android:name="android.intent.category.launcher" /> </intent-filter> </activity> </application> </manifest>
Comments
Post a Comment