I have an application that request DownloadManager to start a download.
What I want to do is launch my app when user clicks on the download notification for the download that my app requested from DownloadManager. Below is the code in BroadcastReceiver for DownloadManager broadcasts.
if (DownloadManager.ACTION_NOTIFICATION_CLICKED.equals(action))
{
long downloadId = intent.getLongExtra(DownloadManager.EXTRA_DOWNLOAD_ID, 0);
long dlRef = getDlRef();
if (downloadId != dlRef) {
Log.d(Constants.TAG, "MY_DL_ID: " + dlRef + " EVENT FOR: " + downloadId);
} else {
Log.d(Constants.TAG, "Starting my activity");
Intent i = new Intent(context, MyActivity.class);
i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(i);
}
}
How can I do that? In above code I get downloadId as 0.
Thanks,
Vinay
You want to be using:
intent.getLongArrayExtra(DownloadManager.EXTRA_NOTIFICATION_CLICK_DOWNLOAD_IDS)
which returns an long array.