[使用DownloadManager下载视频文件时,应用程序在Android 10上崩溃

问题描述 投票:0回答:1

设置setDestinationInExternalPublicDir()时应用程序崩溃

 val videoDir = Environment.getDataDirectory().absolutePath + "/applicationfiles/.tutorial"
downloadRequest.setDestinationInExternalPublicDir(videoDir, videoName)

E / AndroidRuntime:致命异常:主要流程:app.package,PID:19275java.lang.IllegalStateException:不是标准目录之一:/data/applicationfiles/.tutorial在android.os.Parcel.createException(Parcel.java:2079)在android.os.Parcel.readException(Parcel.java:2039)在android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:188)在android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:140)在android.content.ContentProviderProxy.call(ContentProviderNative.java:658)在android.content.ContentProviderClient.call(ContentProviderClient.java:558)在android.content.ContentProviderClient.call(ContentProviderClient.java:546)在android.app.DownloadManager $ Request.setDestinationInExternalPublicDir(DownloadManager.java:569)在app.package.startDownloadingFile(ExerciseTutorialPresenter.kt:159)在app.package.downloadVideoFiles(ExerciseTutorialPresenter.kt:142)

android android-download-manager download-manager
1个回答
0
投票

setDestinationInExternalPublicDir(dirType: String!, subPath: String!)

对于面向Android 10及更高版本的应用程序,此方法的第一个参数setDestinationInExternalPublicDir(dirType: String!, subPath: String!)必须是已知的公共目录之一,例如dirTypeEnvironment.DIRECTORY_DOWNLOADSEnvironment.DIRECTORY_PICTURES

© www.soinside.com 2019 - 2024. All rights reserved.