首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >DownloadManager通知点击意向问题

DownloadManager通知点击意向问题
EN

Stack Overflow用户
提问于 2017-10-18 18:31:36
回答 1查看 643关注 0票数 0

我在我的应用程序中通过downloadManager下载内容。当下载完成和用户点击通知时,我的应用程序将打开。

开始下载:

代码语言:javascript
复制
        request.setAllowedNetworkTypes(DownloadManager.Request.NETWORK_WIFI or DownloadManager.Request.NETWORK_MOBILE)
                .setMimeType(context.getString(R.string.application_mime_type))
                .setTitle(context.getString(R.string.download_title))
                .setDescription(videoName)
                .setDestinationInExternalFilesDir(context,
                        MY_CONTENT_PATH,
                        getFileNameForContent(id, videoName, videoType))
                .setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED)
        manager.enqueue(request)

捕获通知点击:

代码语言:javascript
复制
    <activity
        android:name=".presentation.MainActivity"
        android:screenOrientation="portrait">
        <intent-filter>
            <action android:name="android.intent.action.VIEW" />
            <data android:mimeType="@string/application_mime_type" />
            <category android:name="android.intent.category.DEFAULT" />
        </intent-filter>
    </activity>

MainActivity onCreate():

代码语言:javascript
复制
val dataUri = intent.data
    if (dataUri != null) {
        ...
    }

适用于API 19

dataUri = file:///storage/emulated/0/Android/data/ru.mycompany.myapp/files/filename.mp3

适用于API 25

dataUri=content://com.android.providers.downloads.documents/document/276

我的问题是:不同的android版本或设备有什么不同?我在哪里可以找到关于这方面的文档?

EN

回答 1

Stack Overflow用户

发布于 2017-11-30 17:17:26

这是因为android版本不同,API 19之后的表现有所不同,更多信息可以查看这里:

Android: Getting a file URI from a content URI?

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/46808119

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档