下载具有待定意图的已完成通知

时间:2012-06-14 20:46:18

标签: android notifications android-pendingintent

目前,我正在通知用户下载已完成:

@Override
protected void onHandleIntent(Intent intent) {

    String url = intent.getStringExtra("url");
    DownloadManager.Request request = new DownloadManager.Request(Uri.parse(url));
    request.setDescription("Downloading");
    request.setTitle("Bob_Marley-Jammin.mp3");

    request.allowScanningByMediaScanner();

    request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED);

    request.setDestinationInExternalPublicDir(Environment.DIRECTORY_DOWNLOADS, "Bob_Marley-Jammin.mp3");

    DownloadManager manager = (DownloadManager) getSystemService(Context.DOWNLOAD_SERVICE);
    manager.enqueue(request);

}

}

但是当用户点击通知时,应用程序强制关闭。有人知道为什么吗?

我想要发生的是当用户点击通知时启动特定活动。

这是我的logcat东西:

06-14 18:27:55.069: E/AndroidRuntime(632): java.lang.ExceptionInInitializerError
06-14 18:27:55.069: E/AndroidRuntime(632):  at com.android.providers.downloads.DownloadDrmHelper.getOriginalMimeType(DownloadDrmHelper.java:97)
06-14 18:27:55.069: E/AndroidRuntime(632):  at com.android.providers.downloads.DownloadReceiver.openDownload(DownloadReceiver.java:153)
06-14 18:27:55.069: E/AndroidRuntime(632):  at com.android.providers.downloads.DownloadReceiver.handleNotificationBroadcast(DownloadReceiver.java:104)
06-14 18:27:55.069: E/AndroidRuntime(632):  at com.android.providers.downloads.DownloadReceiver.onReceive(DownloadReceiver.java:74)
06-14 18:27:55.069: E/AndroidRuntime(632):  at android.app.ActivityThread.handleReceiver(ActivityThread.java:2119)
06-14 18:27:55.069: E/AndroidRuntime(632):  at android.app.ActivityThread.access$1500(ActivityThread.java:123)
06-14 18:27:55.069: E/AndroidRuntime(632):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1197)
06-14 18:27:55.069: E/AndroidRuntime(632):  at android.os.Handler.dispatchMessage(Handler.java:99)
06-14 18:27:55.069: E/AndroidRuntime(632):  at android.os.Looper.loop(Looper.java:137)
06-14 18:27:55.069: E/AndroidRuntime(632):  at android.app.ActivityThread.main(ActivityThread.java:4424)
06-14 18:27:55.069: E/AndroidRuntime(632):  at java.lang.reflect.Method.invokeNative(Native Method)
06-14 18:27:55.069: E/AndroidRuntime(632):  at java.lang.reflect.Method.invoke(Method.java:511)
06-14 18:27:55.069: E/AndroidRuntime(632):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
06-14 18:27:55.069: E/AndroidRuntime(632):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
06-14 18:27:55.069: E/AndroidRuntime(632):  at dalvik.system.NativeStart.main(Native Method)
06-14 18:27:55.069: E/AndroidRuntime(632): Caused by: java.lang.UnsatisfiedLinkError: Library drmframework_jni not found; tried [/vendor/lib/libdrmframework_jni.so, /system/lib/libdrmframework_jni.so]
06-14 18:27:55.069: E/AndroidRuntime(632):  at java.lang.Runtime.loadLibrary(Runtime.java:393)
06-14 18:27:55.069: E/AndroidRuntime(632):  at java.lang.System.loadLibrary(System.java:535)
06-14 18:27:55.069: E/AndroidRuntime(632):  at android.drm.DrmManagerClient.<clinit>(DrmManagerClient.java:56)

0 个答案:

没有答案