MTA*_*MTA 1 java android httpclient
我尝试使用Web的HTML,我使用此代码执行此操作:
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();
}
Run Code Online (Sandbox Code Playgroud)
并且总是在response = httpClient.execute(httpGet, localContext);它给我例外,也在我尝试的其他代码
您是否尝试过INTERNET在清单文件中设置权限?
示例代码:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="sample.hello"
android:versionCode="1"
android:versionName="1.0">
<!--- Here is where you put your 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>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
5843 次 |
| 最近记录: |