/ Programming

Launching Android intents from Firefox webapps

Since January, I’ve been interning on the fantastic Firefox for Android team at Mozilla. Sadly, this week is my last, but I want to post about one of the cool projects I’ve been working on!

If you are familiar with Android development, you’ve probably encountered the Intent class a time or two. In short, it allows Android apps to delegate an action or task to a selection of apps on the device, without any knowledge about which apps are available or how those apps work. Examples include sharing a link, sending a message, editing a photo, or dialing a phone number.

This system works really well on Android, and here at Mozilla we adopted a similar pattern when designing Firefox OS that we call Web Activities that allows open web apps to delegate activities to one another.

In Firefox for Android, we wanted webapps to have first-class citizenship, and in Firefox 29 the team released the Web Runtime (or WebRT) that allows open web apps to be installed directly on the users’ device as native APKs.

We wanted to extend Android’s intent system to these WebRT apps too. My project was to build a mapping bridge that allows web apps to launch a web activity and have it interact directly with the native apps on the user’s device. For security reasons, webapps cannot launch arbitrary Android intents and may only use what we have explicitly mapped. If you find another useful mapping, we’d love your contribution!

The first iteration of web activities support landed in yesterday’s nightly build, and for now, is only enabled for web apps. As we begin to understand the security implications, we hope to enable this for all of the web.

We hope that this new support will also help us learn more about how we can standardize a web intent or web activity spec. Eventually, we hope to bring these features to Firefox Desktop and other browsers for a more interoperable web that gives users more freedom to use the apps and services of their choice.