Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

android.os.FileUriExposedException with file:// sound (Android 7) #1181

Closed
matijse opened this issue Jan 4, 2017 · 8 comments
Closed

android.os.FileUriExposedException with file:// sound (Android 7) #1181

matijse opened this issue Jan 4, 2017 · 8 comments

Comments

@matijse
Copy link

matijse commented Jan 4, 2017

When scheduling a notification on Android 7, using a file:// url for the sound, I get an android.os.FileUriExposedException when the notification takes place.

This is only on Android 7 and up, as confirmed by https://developer.android.com/reference/android/os/FileUriExposedException.html

Code

cordova.plugins.notification.local.schedule({
      id: 1,
      title: "title",
      text: "text",
      sound: "file://assets/sounds/dream.mp3",
      at: date
});

Complete error message

01-04 12:39:32.178: E/AndroidRuntime(15198): java.lang.RuntimeException: Unable to start receiver de.appplant.cordova.plugin.localnotification.TriggerReceiver: android.os.FileUriExposedException: file:///storage/emulated/0/Android/data/com.app.id/cache/localnotification/dream.mp3 exposed beyond app through Notification.sound
01-04 12:39:32.178: E/AndroidRuntime(15198): 	at android.app.ActivityThread.handleReceiver(ActivityThread.java:3018)
01-04 12:39:32.178: E/AndroidRuntime(15198): 	at android.app.ActivityThread.-wrap18(ActivityThread.java)
01-04 12:39:32.178: E/AndroidRuntime(15198): 	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1544)
01-04 12:39:32.178: E/AndroidRuntime(15198): 	at android.os.Handler.dispatchMessage(Handler.java:102)
01-04 12:39:32.178: E/AndroidRuntime(15198): 	at android.os.Looper.loop(Looper.java:154)
01-04 12:39:32.178: E/AndroidRuntime(15198): 	at android.app.ActivityThread.main(ActivityThread.java:6077)
01-04 12:39:32.178: E/AndroidRuntime(15198): 	at java.lang.reflect.Method.invoke(Native Method)
01-04 12:39:32.178: E/AndroidRuntime(15198): 	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:865)
01-04 12:39:32.178: E/AndroidRuntime(15198): 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755)
01-04 12:39:32.178: E/AndroidRuntime(15198): Caused by: android.os.FileUriExposedException: file:///storage/emulated/0/Android/data/com.app.id/cache/localnotification/dream.mp3 exposed beyond app through Notification.sound
01-04 12:39:32.178: E/AndroidRuntime(15198): 	at android.os.StrictMode.onFileUriExposed(StrictMode.java:1799)
01-04 12:39:32.178: E/AndroidRuntime(15198): 	at android.net.Uri.checkFileUriExposed(Uri.java:2346)
01-04 12:39:32.178: E/AndroidRuntime(15198): 	at android.app.NotificationManager.notifyAsUser(NotificationManager.java:300)
01-04 12:39:32.178: E/AndroidRuntime(15198): 	at android.app.NotificationManager.notify(NotificationManager.java:284)
01-04 12:39:32.178: E/AndroidRuntime(15198): 	at android.app.NotificationManager.notify(NotificationManager.java:268)
01-04 12:39:32.178: E/AndroidRuntime(15198): 	at de.appplant.cordova.plugin.notification.Notification.showNotification(Notification.java:239)
01-04 12:39:32.178: E/AndroidRuntime(15198): 	at de.appplant.cordova.plugin.notification.Notification.show(Notification.java:224)
01-04 12:39:32.178: E/AndroidRuntime(15198): 	at de.appplant.cordova.plugin.notification.TriggerReceiver.onTrigger(TriggerReceiver.java:45)
01-04 12:39:32.178: E/AndroidRuntime(15198): 	at de.appplant.cordova.plugin.localnotification.TriggerReceiver.onTrigger(TriggerReceiver.java:48)
01-04 12:39:32.178: E/AndroidRuntime(15198): 	at de.appplant.cordova.plugin.notification.AbstractTriggerReceiver.onReceive(AbstractTriggerReceiver.java:75)
01-04 12:39:32.178: E/AndroidRuntime(15198): 	at android.app.ActivityThread.handleReceiver(ActivityThread.java:3011)
01-04 12:39:32.178: E/AndroidRuntime(15198): 	... 8 more
@mherb63
Copy link

mherb63 commented Jan 23, 2017

same here...any work-arounds?

@Sohib
Copy link

Sohib commented Feb 8, 2017

same here

@chevarria
Copy link

same here

@souly1
Copy link

souly1 commented Apr 23, 2017

+1

1 similar comment
@davidlr99
Copy link

+1

@vegham
Copy link

vegham commented May 1, 2017

See my comment for work-around: #1261 (comment)

@matijse
Copy link
Author

matijse commented May 2, 2017

Some time ago I started trying to fix this by adopting the content:// protocol as @vegham said in his comment. You can find my progress at matijse@b75cbf4, but that didn't work yet. I haven't had time to finish it, but it might be a starting point for someone else...

@katzer
Copy link
Owner

katzer commented Oct 31, 2017

Has been fixed with 0.9-beta

@katzer katzer closed this as completed Oct 31, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

9 participants