Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use Android to display the latest files and download list

2025-03-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

This article mainly introduces "how to use Android to display the latest files and download list". In daily operation, I believe many people have doubts about how to use Android to display recent files and download list. The editor consulted all kinds of materials and sorted out simple and easy-to-use methods of operation. I hope it will be helpful to answer the questions of "how to use Android to display recent files and download lists". Next, please follow the editor to study!

Suppose the saved file is File file in external storage, either in the app private directory (untested), or in the download, pictures, and other directories in the root directory of the external storage (no problem found).

The test supports Android 4.09.0.

The first step is to throw violence to the media for scanning, whether you are a picture or not.

If our files are pictures, videos, music and other media files, show them to photo albums and other places

Context.sendBroadcast (new Intent (Intent.ACTION_MEDIA_SCANNER_SCAN_FILE, Uri.fromFile (file)

The second step is to add it to the download list, which is automatically displayed to the most recent file

String mime=MimeTypeMap.getSingleton () .getMimeTypeFromExtension (ext) | "application/octet-stream"; / / empty use of the latter one, how to write quickly?

DownloadManager manager= (DownloadManager) context.getSystemService (Context.DOWNLOAD_SERVICE); manager.addCompletedDownload (file.getName (), file.getName (), true, mime, file.getAbsolutePath (), file.length (), false)

The actual valid ingredient: DownloadManager.addCompletedDownload, after calling, the file is added to the download list and appears in the recent file list. When you want this function, you may not find it even if you are unlucky to find it for a long time.

At this point, the study on "how to use Android to display the latest files and download list" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report