Acting as a Content Type Handler Android

Your application can act as a content type filter—that is, handle common intent actions such as VIEW, EDIT, or SEND for specific MIME types.

A photo application might act as a content type handler for VIEW actions for any graphic formats, such as JPG,PNG, or RAW image file MIME types. Similarly, a social networking application might want to handle intent SEND actions when the underlying data has a MIME type associated with typical social content (for example, text, graphic, or video). This means that any time the user tries to send data (with the MIME types that the social networking application was interested in) from an Android application using an Intent with action SEND, the social networking application is listed as a choice for completing the SEND action request. If the user chooses to send the content using the social networking application, that application has to launch an Activity to handle the request (for example, an Activity that uploads the content to the social networking website to share).

Finally, content type handlers make it easier to extend the application to act as a content provider, provide search capabilities, or include live folder features. Define data records using custom MIME types, so that no matter how an Intent fires (inside or outside the application), the action is handled by the application in a graceful fashion.

To enable your application to act as a content type handler, you need to make several changes to your application:

  • Determine which Intent actions and MIME types your application needs to be able to handle.
  • You need to implement an Activity that can process the Intent action or actions that you want to handle.
  • You need to register that Activity in your application’s Android Manifest file using the <activity> tag as you normally would. You then need to configure an <intent-filter> tag for that Activity within your application’s Android Manifest file, providing the appropriate intent action and MIME types your application can process.

All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd DMCA.com Protection Status

Android Topics