Android API for detecting new media from inbuilt camera & mic


Is there any elegant way in the Android API for detecting new media when it is written to the device? I


There's a special broadcast Intent that should get called every time an application writes anything new to the Media Store:


The Broadcast Intent includes the path to the new file, accessible through the Intent.getDataString() method.

To listen for it, just create a BroadcastReceiver and register it using an IntentFilter as shown below:

registerReceiver(new BroadcastReceiver() {
    public void onReceive(Context context, Intent intent) {
      String newFileURL = intent.getDataString();
      // TODO React to new Media here.  
  }, new IntentFilter(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE));

This will only work for files being inserted into one of the Media Store Content Providers. Also, it depends on the application that's putting it there broadcasting the intent, which all the native (Google) application do.

The problem may not be in the table itself, but in the system tables that have to be updated in order to create the trigger. If you're doing any other kind of DDL as part of your normal processes they could be holding it up.

Use sp_who to find out where the block is coming from then investigate from there.

By : Tom H

This video can help you solving your question :)
By: admin