Tuesday 7 June 2011

Android intents, apps talking to each other

Android intents are one of the most powerful features of the platform. They allow applications to provide deep integration to other apps and extend other apps with their features. Android applications don't work in silos but integrate with each others and offer their services to other applications.

Probably the most common use of intents is to offer users an option to share something that the application produces. It often a media file, text, or other information. But there are much more that can be done with intents.

Power of intents, an example
This example of Android intents demonstrates how different apps that handle and share images extend each others' functionality.

Image is first created in the Androidify app.



Once created the image is shared to Color Touch.



After editing the image and adding some effects the image is shared to Postcard Express.




The resulting postcard is then shared to twitter app which is then used to upload it to twitter with an added comment without user ever having to think about saving and opening a file or finding an image from gallery.



How Android intents work?
Android intents are very simple to use. Basic idea is that an app can tell the OS what it can do. An app basically raises its hand to offer its services. Other apps can then tell the OS that they need someone to handle something they have.

The sending application defines a action of intent, for example to view somehing, and data, for example image, Android OS then figures out which apps can handle it. If there are more than one apps that can handle the intent OS will offer user a choice.


Social networks
Sharing from an app to social networks is very common use case. Many social networks like twitter and Facebook provide APIs for apps to directly integrate to their services. In some cases using the API has benefits but using them for simple sharing tasks could just make user experience overly complicated.

Take the app pulse for example. It offers sharing directly to twitter and Facebook and a third option to use Android's intents. Tapping the twitter button will bring up web view that prompts user's twitter credentials and explains that the user must give pulse news permission to do pretty much anything on twitter on the user's behalf.



If user taps the third option instead she or he will be shown the common selection of applications that can handle sharing text. If the user has a twitter app already installed it will be present in the list. Once user taps it the twitter app opens with prefilled text that was shared.
Which approach is simpler to the user?


In this case the benefit of using intens are clear

  • No need to give any permissions to third party apps
  • User doesn't need to login separately
  • User can use the familiar UI of the app they have chosen for the social network


Other actions
Intens are not only for sharing images, links or text. In the Google I/O app user is guided to Android Market if Catch Notes app is not installed. The intent system opens Android Market app from the correct place without user having to do any manual search.


Once user install the Catch Notes app the I/O app offers deep interface to Catch Notes app's note taking functionality. Creating a new note even pre-fills some information to the created note.


Many actions in Android are handled by intents. That means that apps can hook into them and replace almost any default functionality. It is possible to make an app that responds to dialer intent or even pressing the home button.

 

It is also possible to offer service for taking photos or selecting them.



Resources




Conclusion
Android intents can make apps talk each others. Instead of individual apps we have a web of apps extending each others' functionality.

When designing your app it is much better to let an existing apps to do a task that is not your app's core functionality, like sharing to twitter, than implementing and maintaining it in your app.










1 comment:

  1. good one.....
    thanks for the information

    ReplyDelete