How to Run Media Scanner in Android

Hey guys, in this tutorial we are going to learn how you can run media scanner with in your android application. It might so happen that your newly clicked image in not visible to user to select on intent to gallery. So here we need to scan our gallery.


To start our media scanner is not a difficult task. We just have to call intent. So without further ado lets get started with our media scanner.

Building our android application

  • The main thing in android is user interface. So that user can interact with it. Our user interface will consist of on button i.e to start the media scanner.

    Media scanner

  • Now will add the function for media scanner. In this function we have to check if device is running on lower version then KITKAT. If yes then we have to use older version of intent if not then use function which is supported on higher version of KITKAT.

  • In the above function we have add a file path to get the path. This path is of newly added or clicked image or media file. If device is running on higher version of KITKAT then add the file in the Intent setData method. Else device is running on lower version of KITKAT then scan the whole media.
  • Now connecting our media UI in java class. So that user can interact with it and invoke media scan command.

  • Combining the whole Java class as one. With onclick() event.

  • Last but not the least don’t forget to add broadcast intent in AndroidMainfest.xml.


Our app is ready to be deployed on devices. If you have any query then please do comment down below. I will be happy to help you. Thank you 🙂 ….

You may also like...

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.