nceState);
setContentView(R.layout.main);
btnGO = (Button) findViewById(R.id.go);
btnGO.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Uri url = Uri .parse("192.168.2.143:8620/Struts2Test/include.jsp");
Intent intent = new Intent(Intent.ACTION_VIEW, url);
startActivity(intent);
}
});
}
}
(2)为了解决网络的延迟问题,我们可以使用线程把手机客户端程序继续完善,采用了线程后可以解决网络的延迟,应答迟缓的现象,以下是用线程实现的核心代码:
public class WebViewDemo extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
setContentView(R.layout.main);
webView1 = new WebView(this);
webView1
.loadData(
"Can I focus?
No I cannot!.",
"text/html", "utf-8");
this.setContentView(webView1);
Logger.info("Download Faild _=> " + webView1.canGoBack());
webView = new WebView(this);
webView.loadUrl("192.168.2.143:8620/Struts2Test/include.jsp");
new Thread(new WebDownloadListener(this)).start();
}
WebView webView1;
class WebDownloadListener implements Runnable, DownloadListener {
WebViewDemo wd;
WebDownloadListener(WebViewDemo wd){
this.wd = wd;
}
//使用线程代码:
public void run() {
int j=0;
StringBuffer sb = new StringBuffer();
sb.append("正在连接网络");
while (true) {
try {
Thread.sleep(4 * 1000);
j++;
sb.append(".");
webView1 = new WebView(wd);
webView.loadUrl("192.168.2.143:8620/Struts2Test/include.jsp");
上一篇:
二手房信息管理系统开发(原创)毕业论文
下一篇:
试论APP广告在手机中的应用