Skip to end of metadata
Go to start of metadata

Mission: In this lab, you will learn how to open a device’s other native apps from inside another app. You will also learn how to make your app be able to be opened from within another app.

Specification:  You will create an app that will be able to open other apps such as maps, youtube, and sms. You will then make another app that will open your first app.

  1. Create a new Alloy mobile project inside Titanium Studio. In the index view, create five buttons with the labels, Open Maps, Open SMS, Open Dialer, Open YouTube, and Open App Store / Market.

  2. In the index controller, add a click event listener for each of these buttons. Then use the Ti.Platform.openURL() function to open a corresponding url for each of these tasks. These urls are:

    1. Maps: use maps:// or http:// as the URL scheme for iOS & Android respectively. Use this as the map location:,+Mountain+View,+CA&hl=en&sll=42.746632,-75.770041&sspn=6.364676,10.305176&oq=44&hnear=440+Bernardo+Ave,+Mountain+View,+Santa+Clara,+California+94043&t=m&z=17

    2. SMS: use sms:+ and a number of your choice

    3. Phone: use tel:// and a number of your choice

    4. YouTube: use as the target URL

    5. Store: for iOS, use and for Android use market://details?

  3. Build your application and test that these buttons perform their assigned functions.

  4. Now we will modify this app so it can be opened by the second app.

  5. For iOS, add the following code to the tiapp.xml file, and make sure the app ID matches the app ID you chose for your app.

  6. For Android: you must have built for the emulator at least once, the follow these steps:

    1. Open build/android/AndroidManifest.xml

    2. Copy the <application> tag and all its contents

    3. In tiapp.xml, modify the <android> tag to remove the '/' that makes it an empty tag; add a closing </android> tag

    4. Within that tag, add <manifest></manifest> tags

    5. Within the manifest tags, paste the tags you copied from the generated manifest

    6. Following the </intent-filter> closing tag, add the following code:

  7. To work around a tooling default, we'll need to build the project from the command line with an additional flag. First, clean the project in Studio. Then, open a terminal window and navigate to your project's root directory. Enter the following command (make sure to specify the appropriate target platform, though):

    1. titanium build --platform ios --force-copy

  8. Create a second Alloy app with a name and app ID of your choice. The app should have three buttons in its index view. They should have the labels: “Open Target app”, “In Target app, open Maps”, and “In Target app, open YouTube”. Give these buttons the action properties of “”, “maps”, and “youtube” respectively. Also, give all the buttons the onClick property of “doClick”

  9. In the index controller insert the following doClick function before opening the window:

  10. Build and run the application with the command line technique described above. Once the app is open, you can press the Open Target App button, and your first app should open.

  11. Close the app, and we will now edit our first app to accept arguments when it is called to be opened.

  12. In the URLSchemes app, add the following code to the alloy.js file:

  13. Now, in the index controller add the following code to the beginning of the file:





  14. Build both app as you did before, and now if you click any of the buttons in the second app we made, the described action should be taken by the first app.

    You can download the completed applications from: this link.

  • No labels