是否有一种方法可以在将文件添加到特定目录后启动JobService?
我尝试使用MediaStore.Files.getContentUri('external')
,但没有用。
这是我在MainActivity中安排作业的代码:
val dispatcher = FirebaseJobDispatcher(GooglePlayDriver(context))
val mediaFileAddedJob = dispatcher.newJobBuilder()
.setService(MediaFileReceivedJob::class.java)
.setTag("my-media-file-listener")
.setRecurring(true)
.setLifetime(Lifetime.FOREVER)
.setTrigger(Trigger.contentUriTrigger(listOf(
ObservedUri(MediaStore.Files.getContentUri("external"), ObservedUri.Flags.FLAG_NOTIFY_FOR_DESCENDANTS),
ObservedUri(MediaStore.Files.getContentUri("internal"), ObservedUri.Flags.FLAG_NOTIFY_FOR_DESCENDANTS)
)))
.setReplaceCurrent(true)
.setRetryStrategy(RetryStrategy.DEFAULT_EXPONENTIAL)
.build()
dispatcher.mustSchedule(mediaFileAddedJob)
我要观察的文件是opus
音频文件,但是由于某些原因,当将这些特定文件添加到目录中时,MediaStore.Audio.Media.EXTERNAL_CONTENT_URI
和MediaStore.Audio.Media.INTERNAL_CONTENT_URI
不起作用>