android - Download Manager crashing when calling from child activity -
i facing head scratching issue , not able resolve. can here help...
i have 1 activity (parent) starts activity(child). , initiating download manager child activity. when clicking button on child activity view downloads, opens download manager , shows downloads. till point goes fine. when return download view window pressing return key, of time crashing (specially when download completed). don't know why..
note: when initiate download manager parent activity, works well. need child. appreciated.
i starting child activity like:
lv.setonitemclicklistener(new adapterview.onitemclicklistener(){ public void onitemclick(adapterview<?> p, view v, int position, long id) { intent = new intent(audiodownloadactivity.this,cdpageactivity.class); i.putextra("audiocdurl", "http://bkdrluhar.com/00-htm/" + hiddentext); i.setflags(intent.flag_activity_new_task); audiodownloadactivity.this.startactivity(i); }});
in child activity, defining , initiating broadcast receiver download manager like:
private long enqueue; private downloadmanager dm; /*some code */ broadcastreceiver receiver = new broadcastreceiver() { @override public void onreceive(context context, intent intent) { string action = intent.getaction(); if (downloadmanager.action_download_complete.equals(action)) { query query = new query(); query.setfilterbyid(enqueue); cursor c = dm.query(query); if (c.movetofirst()) { int columnindex = c.getcolumnindex(downloadmanager.column_status); if (downloadmanager.status_successful == c.getint(columnindex)) { } } } } }; registerreceiver(receiver, new intentfilter(downloadmanager.action_download_complete)); /*some code */ dm = (downloadmanager) getsystemservice(download_service); request request = new request(uri.parse(downloadurl)); request.setallowednetworktypes(downloadmanager.request.network_wifi | downloadmanager.request.network_mobile) .setallowedoverroaming(true).settitle("bk asset") .setdescription(tempfile) .setdestinationuri(uri.fromfile(new file(mainactivity.downloadfilelocation,tempfile))); request.setnotificationvisibility(downloadmanager.request.visibility_visible_notify_completed); enqueue = dm.enqueue(request);
and button press pops shows downloads:
public void onaudiocddownloadclick(view v){ intent = new intent(); i.setaction(downloadmanager.action_view_downloads); startactivity(i); }
log cat crash is:
fatal exception: main java.lang.runtimeexception: error receiving broadcast intent { act=android.intent.action.download_complete flg=0x10 pkg=com.os.bkdownloader (has extras) } in com.os.bkdownloader.audiodownloadactivity$1@416b8ad8 @ android.app.loadedapk$receiverdispatcher$args.run(loadedapk.java:737) @ android.os.handler.handlecallback(handler.java:605) @ android.os.handler.dispatchmessage(handler.java:92) @ android.os.looper.loop(looper.java:137) @ android.app.activitythread.main(activitythread.java:4517) @ java.lang.reflect.method.invokenative(native method) @ java.lang.reflect.method.invoke(method.java:511) @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:995) @ com.android.internal.os.zygoteinit.main(zygoteinit.java:762) @ dalvik.system.nativestart.main(native method) caused by: java.lang.nullpointerexception @ com.os.bkdownloader.audiodownloadactivity$1.onreceive(audiodownloadactivity.java:158) @ android.app.loadedapk$receiverdispatcher$args.run(loadedapk.java:728)
Comments
Post a Comment