OPhone开发之下载
2010-10-19 20:56:09 来源:WEB开发网32. super.onCreate(savedInstanceState);
33. setContentView(R.layout.main);
34. txt_process = (TextView) findViewById(R.id.txt_process);
35. btn_start = (Button) findViewById(R.id.btn_start);
36. btn_pause = (Button) findViewById(R.id.btn_pause);
37. btn_resume = (Button) findViewById(R.id.btn_resume);
38. btn_cancel = (Button) findViewById(R.id.btn_cancel);
39. btn_retry = (Button) findViewById(R.id.btn_retry);
40.
41. btn_start.setOnClickListener(new OnClickListener() {
42. public void onClick(View v) {
43. start();
44. }
45. });
46. btn_pause.setOnClickListener(new OnClickListener() {
47. public void onClick(View v) {
48. pause();
49. }
50. });
51. btn_resume.setOnClickListener(new OnClickListener() {
52. public void onClick(View v) {
53. resume();
54. }
55. });
56. btn_cancel.setOnClickListener(new OnClickListener() {
57. public void onClick(View v) {
58. cancel();
59. }
60. });
61. btn_retry.setOnClickListener(new OnClickListener() {
62. public void onClick(View v) {
63. retry();
64. }
65. });
66. }
67.
68. private void start() {
69. ContentValues values = new ContentValues();
70. values.put("title", "apologize.mp3");
71. values.put("uri", URL);
72. values.put("notificationpackage", getPackageName());
73. values.put("notificationclass", TestDownload.class.getName());
74. values.put("visibility", 1);
75. values.put("description", Uri.parse(URL).getHost());
76. values.put("storepath", "/sdcard/download/");
77. contentUri = getContentResolver().insert(
更多精彩
赞助商链接