मैं डाउनलोड करने की स्थिति प्राप्त करने के लिए DownloadManager का उपयोग करता हूं, लेकिन यह अभी भी काम नहीं करता है, यह कभी भी if(c.moveToFirst())
की स्थिति में कूदता नहीं है और मुझे नहीं पता कि क्यों। क्या कोई मेरी मदद कर सकता है, कृपया?डाउनलोड करने की स्थिति कैसे प्राप्त करें?
private final BroadcastReceiver myReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
String action = intent.getAction();
if(Intent.ACTION_SCREEN_OFF.equals(action)) {
DownloadManager downloadMgr = (DownloadManager)getSystemService(DOWNLOAD_SERVICE);
DownloadManager.Query query = new DownloadManager.Query();
query.setFilterByStatus(DownloadManager.STATUS_FAILED|DownloadManager.STATUS_PENDING|DownloadManager.STATUS_RUNNING|DownloadManager.STATUS_SUCCESSFUL);
Cursor c = downloadMgr.query(query);
if(c==null) {
//
}
else {
if(c.moveToFirst()) {
int columnIndex = c.getColumnIndex(DownloadManager.COLUMN_STATUS);
int status = c.getInt(columnIndex);
if(status == DownloadManager.STATUS_RUNNING){
//do something
}
}
}
}
}
};
जाहिर है अपने कर्सर खाली है? – Blundell
एचएम? और मैं इसे कैसे हल कर सकता हूं? – Adam
ऐसा लगता है कि कर्सर खाली नहीं है, क्योंकि यह हमेशा के लिए जाता है, अगर नहीं (सी == शून्य)। – Adam