Android Mediascanner Usage Profile

Source: Internet
Author: User


1. Performing a scanMediascanner is only executed when the system is powered on, other scenarios require manual scanning (shooting, downloading, etc.).
A manual scan is performed by sending a Mediascanner broadcast:
1.1 Scan the specified file:

Intent.action_media_scanner_scan_file


1.2 Scan The specified directory:

"Android.intent.action.MEDIA_SCANNER_SCAN_DIR"

<span style= "FONT-SIZE:14PX;" >sendbroadcast (New Intent (Intent.action_media_scanner_scan_file, Uri.fromfile (new FILE)); Sendbroadcast ( Intent ("Android.intent.action.MEDIA_SCANNER_SCAN_DIR", Uri. ( File (dir)));</span>


2. Monitoring Scan2.1 Start scanning:intent.action_media_scanner_started
2.2 Scan Complete:

Intent.action_media_scanner_finished


<span style= "FONT-SIZE:14PX;" >intentfilter filter = new Intentfilter (); filter.addaction (intent.action_media_scanner_finished); Filter.addaction (intent.action_media_scanner_started); Registerreceiver (receiver, filter);</span>



3. Monitoring SDcard
The SD card is plugged in and is already mounted intent.action_media_mounted
SD card exists, but not mounted intent.action_media_unmounted
SD card removed Intent.action_media_removed
SD card is shared as USB mass storage, mount is lifted Intent.action_media_shared
The SD card has been unplugged from the SD card slot, but the mount point has not been lifted Intent.action_media_bad_removal
Start scanning intent.action_media_scanner_started
Scan complete Intent.action_media_scanner_finished

Android Mediascanner Usage Profile

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.