Skip to content

Instantly share code, notes, and snippets.

@dawsontoth
Created February 23, 2011 16:02
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save dawsontoth/840600 to your computer and use it in GitHub Desktop.
Save dawsontoth/840600 to your computer and use it in GitHub Desktop.
Launch Custom Android Application from Android Browser with Titanium Mobile
var win = Ti.UI.createWindow({ backgroundColor: '#fff' });
win.add(Ti.UI.createLabel({ text: 'Type appcelerator.com in a browser, and this app will get launched. Try it!' }));
win.open();
var activity = Ti.Android.currentActivity;
var win = Ti.UI.currentWindow;
activity.addEventListener("create", function(e) {
win.add(Ti.UI.createButton({title: 'Our app was launched when you typed appcelerator.com!'}));
});
<?xml version="1.0" encoding="UTF-8"?>
<ti:app xmlns:ti="http://ti.appcelerator.org">
...
<android xmlns:android="http://schemas.android.com/apk/res/android">
<activities>
<activity url="launchFromURL.js">
<intent-filter>
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.DEFAULT"/>
<category android:name="android.intent.category.BROWSABLE"/>
<data android:scheme="http" android:host="www.appcelerator.com"/>
</intent-filter>
</activity>
</activities>
</android>
...
</ti:app>
@dawsontoth
Copy link
Author

Inspired by Marshall's https://gist.github.com/839017

@FokkeZB
Copy link

FokkeZB commented Aug 23, 2013

Just for people who pass by here. This code doesn't work on SDK 3.1.2.GA on Android 4.1.2. The app never boots, only shows black screen.

@ajinkyapote1
Copy link

When i give custom url to launch application in chrome browser it redirects to the Google search instead of launching my application.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment