發送網頁我使用本教程通過藍牙
http://developer.android.com/resources/samples/BluetoothChat/index.html.
我想通過一個Android手機訪問互聯網,然後將其發送給其他手機通過藍牙。 雖然網頁的顯示速度非常慢,網頁顯示不正確。我試着逐行發送它並逐行將其加載到webview中,然後使用StringBuilder將其作爲整個塊加載到webview中,嘗試將它作爲整個塊加載並由StringBuilder加載爲塊。我也提供了所有權限。
uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
uses-permission android:name="android.permission.BLUETOOTH" />
uses-permission android:name="android.permission.INTERNET" />
我通過
HttpClient client = new DefaultHttpClient();
HttpPost httppost = new HttpPost("http://www.sheldonbrown.com/web_sample1.html");
HttpResponse response = client.execute(httppost);
in = new BufferedReader(new InputStreamReader(response.getEntity().getContent()));
String line = "";
String NL = System.getProperty("line.separator");
while ((line = in.readLine())!= null) {
line = in.readLine();
sendMessage(line);
訪問互聯網,然後檢索它的另一端加載web視圖。
case MESSAGE_READ:
byte[] readBuf = (byte[]) msg.obj;
// construct a string from the valid bytes in the buffer
String readMessage = new String(readBuf, 0, msg.arg1);
add = readMessage + add;
try {
mWebView.loadData(URLEncoder.encode(add,"utf-8").replaceAll("\\+"," "),
"text/html", "utf-8");
} catch (UnsupportedEncodingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
break;
其中add是String add =「」;
問題是什麼?你卡在哪裏? – 2012-04-23 03:14:01
雖然在藍牙聊天應用程序中籤入數據時無論何時發送數據,但網頁上的問題確實緩慢地上傳到webview(應用程序有時沒有響應)。如果網頁很大,所有的數據都不顯示。 – Kamran 2012-04-23 10:11:54
使用spp發送數據。用於串行傳輸... – 2012-04-30 08:14:55