Wednesday, October 22, 2014

Inserting Media Using the Media Scanner
If you have recorded new media of any kind, the MediaScannerConnection class provides the
scanFile method as a simple way for you to add it to the Media Store without needing to construct
the full record for the Media Store Content Provider.


Before you can use the scanFile method to initiate a content scan on your fi le, you must call
connect and wait for the connection to the Media Scanner to complete. This call is asynchronous,
so you will need to implement a MediaScannerConnectionClient to notify you when the connection
has been made. You can use this same class to notify you when the scan is complete, at which
point you can disconnect your Media Scanner Connection.
This sounds more complex than it is. Listing 15-34 shows the skeleton code for creating a new
MediaScannerConnectionClient that defi nes a MediaScannerConnection, which is used to add a
new fi le to the Media Store.

0 comments:

Post a Comment

Design by hons.CISKO | Blogger Theme by CISKO