Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-9416] Android: Can't create a custom url for the app

GitHub Issuen/a
TypeBug
PriorityMedium
StatusClosed
ResolutionFixed
Resolution Date2012-07-06T10:11:37.000+0000
Affected Version/sRelease 2.0.1
Fix Version/sSprint 2012-13 Core, Release 2.1.1, Release 3.0.0
ComponentsAndroid
Labelscore, qe-port
ReporterMauro Parra-Miranda
AssigneeAllen Yeung
Created2012-06-06T10:23:24.000+0000
Updated2013-12-03T21:44:10.000+0000

Description

Problem Description

Customer wants to registrate his own url in android, so he can open the app with something like this://is.sparta from the browser in android. We got a really nice recipe on this, but it's not working anymore.

Actual Results

The custom url is not registered.

Expected Results

The custom url should work nice.

Test case:

1. Create mobile project. 2. Add this to the app.js:
var win = Ti.UI.createWindow({ backgroundColor: '#fff' });
win.add(Ti.UI.createLabel({ text: 'Type http://www.appcelerator.com in a browser, and this app will get launched. Try it!' }));
win.open();
3. Add this to launchFromURL.js:
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 http://www.appcelerator.com!'}));
});
4. Add this to the tiapp.xml
 <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>

Extra info

Part of our research was: Generic for Android: http://stackoverflow.com/questions/3469908/make-a-link-in-the-android-browser-start-up-my-app/3472228 From Dawson: https://gist.github.com/840600

Comments

  1. Allen Yeung 2012-06-29

    PR Ready: https://github.com/appcelerator/titanium_mobile/pull/2492 For testing we will need to use a local web server. For some cases, the browser does not resolve "http://www.appcelerator.com" correctly if you type it directly into the url box. If you click on a link that is directly to 'http://appcelerator.com' then it always works correctly. This is native android behavior and we don't do anything on the titanium end: 1. Run an app with the code sample above 2. On a Mac: create a test.html file under ~/Sites/test.html 3. Add the following in test.html:
       <!DOCTYPE html>
       <html>
       <body>
       <a href="http://www.appcelerator.com">click me!</a>
       </body>
       </html>
       
    4. Under system preferences > sharing, check off "web sharing" 5. Once you have done this, there should a url for your site, something like: http://192.168.1.104/~your_username/ 6. On your phone, connect to the same wifi network as your laptop, and type http://192.168.1.104/~your_username/test 7. Click on the "click me" link 8. It should prompt you to open either a browser or your app. Choose to open with your app. Expected Result: Your app should open with a button with the success message Actual Result: Currently, the app will open with a runtime error
  2. Mauro Parra-Miranda 2012-07-04

    Thanks! Tested this on my environment and worked fine! Best, Mauro
  3. Shyam Bhadauria 2012-07-17

    Environment used for verification - Tested with Titanium SDK: 2.1.1.v20120716180600 Tested with Titanium  Studio: 2.1.1.201207161421 Device - Android 2.2.2 LG-P970 Machine OS - MAC 10.7.3

JSON Source