开发学院手机开发Ophone 开发 OPhone开发之下载 阅读

OPhone开发之下载

 2010-10-19 20:56:09 来源:WEB开发网   
核心提示:1. URL url = new URL(xmlURL);2. URLConnection con = url.openConnection();3. InputStream in = con.getInputStream();4. ...还可以利用org.apache.http包的一些类:复制到剪贴板 Java代码1

1. URL url = new URL(xmlURL);

2. URLConnection con = url.openConnection();

3. InputStream in = con.getInputStream();

4. ...

还可以利用org.apache.http包的一些类:

复制到剪贴板 Java代码

1. DefaultHttpClient httpclient = new DefaultHttpClient();

2. HttpGet req = new HttpGet(url);

3. HttpResponse response = httpclient.execute(req);

4. HttpEntity resEntity = response.getEntity();

5. InputStream is = resEntity.getContent();

6. ...

由于篇幅关系,这里就不一一介绍了。文后将附上利用DownloadManager下载的代码与AndroidManifest.xml。

附录:

复制到剪贴板 Java代码

1. TestDownload.java

2.

3. package com.OPhone.test;

4.

5. import android.app.Activity;

6. import android.content.ContentUris;

7. import android.content.ContentValues;

8. import android.database.ContentObserver;

9. import android.database.Cursor;

10. import android.net.Uri;

11. import android.os.Bundle;

12. import android.os.Handler;

13. import android.view.View;

14. import android.view.View.OnClickListener;

15. import android.widget.Button;

16. import android.widget.TextView;

17.

18. public class TestDownload extends Activity {

19.

20. private final String URL = "http://192.168.2.172/share/test/apologize.mp3";

21. private Cursor mDownloadCursor;

22. private Uri contentUri;

23. private Button btn_start;

24. private Button btn_pause;

25. private Button btn_resume;

26. private Button btn_cancel;

27. private Button btn_retry;

28. private TextView txt_process;

29.

30. @Override

31. public void onCreate(Bundle savedInstanceState) {

上一页  1 2 3 4 5 6 7 8  下一页

Tags:OPhone 开发 下载

编辑录入:爽爽 [复制链接] [打 印]
[]
  • 好
  • 好的评价 如果觉得好,就请您
      0%(0)
  • 差
  • 差的评价 如果觉得差,就请您
      0%(0)
赞助商链接