我尝试使用DownloadManager执行下载文件.除LG设备外一切正常.这是我的代码:
private void downloadFile(FileInfo fileInfo) {
private DownloadManager manager = (DownloadManager) MyApp.getSingleton().
getApplicationContext().getSystemService(Context.DOWNLOAD_SERVICE);
DownloadManager.Request request = new DownloadManager.Request(Uri.parse("https://"
+ MyPreference.getInstance().getBaseUrl()
+ "/api/v3/files/"
+ fileId
+ "/get"));
request.setDescription(MyApp.getSingleton().getApplicationContext().getString(R.string.downloading));
request.setTitle(fileInfo.getmName());
request.addRequestHeader("Authorization", "Bearer " + MyPreference.getInstance().getAuthToken());
request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED);
File dir = new File(FileUtil.getInstance().getDownloadedFilesDir());
if(!dir.exists()){
dir.mkdirs();
}
request.setDestinationUri(Uri.fromFile(new File(FileUtil.getInstance().getDownloadedFilesDir() + File.separator + fileInfo.getmName())));
downloadId = manager.enqueue(request);
new Thread(() -> {
boolean downloading = true;
while (downloading) {
DownloadManager.Query q = new DownloadManager.Query();
q.setFilterById(downloadId);
Cursor cursor = manager.query(q);
cursor.moveToFirst();
int bytes_downloaded = 0;
long …Run Code Online (Sandbox Code Playgroud) 我为Cordova项目开发了android插件,我遇到了一个问题:合并文件.特别是资源文件.大多数插件都有相同的资源文件,如strings.xml,我想合并它们.我在谷歌搜索了几天,但找不到答案.
我应该在我的插件的plugin.xml中写什么?源文件标签只是添加文件.Config-file标签允许我在文件中添加一些行,但如果我有很多行,那就太不舒服了.有合并文件的命令吗?