第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定

為什么是空白的?

package com.example.http;


import java.io.BufferedReader;

import java.io.IOException;

import java.io.InputStreamReader;

import java.net.HttpURLConnection;

import java.net.MalformedURLException;

import java.net.URL;


import android.os.Handler;

import android.webkit.WebView;


public class HttpThread extends Thread{

private String url;

private WebView webview;

private Handler handler;

public HttpThread(String url,WebView webview,Handler hanlder){

this.url=url;

this.webview=webview;

this.handler=hanlder;

}

@Override

public void run() {

try {

//URL統(tǒng)一定位符的一個(gè)縮寫

URL httpUrl=new URL(url);

//進(jìn)行網(wǎng)絡(luò)訪問:

try {

HttpURLConnection conn=(HttpURLConnection) httpUrl.openConnection();

? ?//設(shè)置請(qǐng)求超時(shí)的時(shí)間

conn.setReadTimeout(5000);

//設(shè)置網(wǎng)絡(luò)請(qǐng)求的方式:一般情況下通過Get訪問

conn.setRequestMethod("GET");

//拿到網(wǎng)頁(yè)回傳的信息StringBuffer(作為緩沖)

final StringBuffer sb=new StringBuffer();

//1.InputStreamReader副流轉(zhuǎn)換為字節(jié)流;通過getInputStream()拿到一個(gè)獨(dú)入流

BufferedReader readr=new BufferedReader(new InputStreamReader(conn.getInputStream()));

String str;

//如何拿到返回的信息:循環(huán)讀出流的數(shù)據(jù);

//1.readLine()表示讀一行,不等于空的情況下讓他繼續(xù)讀;

while((str=readr.readLine())!=null){

//通過sb.append填充數(shù)據(jù)

sb.append(str);

}

handler.post(new Runnable() {

@Override

public void run() {

webview.loadData(sb.toString(),"IE=edge,chrome=18", null);

}

});

} catch (IOException e) {

// TODO Auto-generated catch block

e.printStackTrace();

}

} catch (MalformedURLException e) {

// TODO Auto-generated catch block

e.printStackTrace();

}

}


}

package com.example.http;


import android.os.Bundle;

import android.os.Handler;

import android.support.v7.app.ActionBarActivity;

import android.webkit.WebView;



public class MainActivity extends ActionBarActivity {

private WebView webview;

private Handler hanlder=new Handler();


? ? @Override

? ? protected void onCreate(Bundle savedInstanceState) {

? ? ? ? super.onCreate(savedInstanceState);

? ? ? ? setContentView(R.layout.activity_main);

? ? ? ? webview=(WebView) findViewById(R.id.webView1);

? ? ? ? new HttpThread("http://www.hao123.com/?tn=90259734_hao_pg", webview, hanlder).start();

? ? }



? ??

}

<?xml version="1.0" encoding="utf-8"?>

<manifest xmlns:android="http://schemas.android.com/apk/res/android"

? ? package="com.example.http"

? ? android:versionCode="1"

? ? android:versionName="1.0" >


? ? <uses-sdk

? ? ? ? android:minSdkVersion="8"

? ? ? ? android:targetSdkVersion="21" />


? ? <application

? ? ? ? android:allowBackup="true"

? ? ? ? android:icon="@drawable/ic_launcher"

? ? ? ? android:label="@string/app_name"

? ? ? ? android:theme="@style/AppTheme" >

? ? ? ? <activity

? ? ? ? ? ? android:name=".MainActivity"

? ? ? ? ? ? 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>

? ? <uses-permission android:name="android.permission.INTERNET"/>


? ? ? ? ?


</manifest>


正在回答

3 回答

我也是空白

0 回復(fù) 有任何疑惑可以回復(fù)我~

我的也是╭∩╮(︶︿︶)╭∩╮鄙視你!(+﹏+)~狂暈

0 回復(fù) 有任何疑惑可以回復(fù)我~

我這里也是空白的,沒找到原因!

0 回復(fù) 有任何疑惑可以回復(fù)我~

舉報(bào)

0/150
提交
取消
Android中的Http通信
  • 參與學(xué)習(xí)       64653    人
  • 解答問題       347    個(gè)

了解Android-http網(wǎng)絡(luò)編程應(yīng)用,常見忘了請(qǐng)求相關(guān)應(yīng)用

進(jìn)入課程

為什么是空白的?

我要回答 關(guān)注問題
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)