发送网页我使用本教程通过蓝牙
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