OPhone开发之下载
2010-10-19 20:56:09 来源:WEB开发网78. Uri.parse("content://downloads/download"), values);
79. mDownloadCursor = query();
80. DownloadObserver observer = new DownloadObserver();
81. getContentResolver()
82. .registerContentObserver(contentUri, true, observer);
83. };
84.
85. private void resume() {
86. ContentValues values = new ContentValues();
87. values.put("control", 0);
88. getContentResolver().update(contentUri, values, null, null);
89. };
90.
91. private void pause() {
92. ContentValues values = new ContentValues();
93. values.put("control", 10);
94. getContentResolver().update(contentUri, values, null, null);
95. };
96.
97. private void cancel() {
98. getContentResolver().delete(contentUri, null, null);
99. };
100.
101. private void retry() {
102. ContentValues values = new ContentValues();
103. values.put("control", 10);
104. values.put("status", 195);
105. getContentResolver().update(contentUri, values, null, null);
106. };
107.
108. private Cursor query() {
109. String selection = "_id = '" + ContentUris.parseId(contentUri) + "'";
110. return managedQuery(Uri.parse("content://downloads/download"),
111. new String[] { "total_bytes", "current_bytes" }, selection,
112. null, null);
113. }
114.
115. private int point = 0;
116.
117. private class DownloadObserver extends ContentObserver {
118. public DownloadObserver() {
119. super(new Handler());
120. }
121.
122. @Override
123. public void onChange(boolean flag) {
124. if (mDownloadCursor.getCount() < = 0) {
更多精彩
赞助商链接