tags:

views:

164

answers:

1

I'm trying to figure out how to launch an activity in my app from a custom URI such as myapp://myuriactivity

I've read a lot about the intent and intent filters in the android references and also read several examples, but for some reason I can't get my simple test to work. Below is my manifest file, can anyone tell me what I'm doing wrong? With the below file, if I open the browser and try to navigate to http://org.test.launchtest it just says the page doesn't exist. Shouldn't this work?

<?xml version="1.0" encoding="utf-8"?>

<activity android:name=".MyUriActivity">
        <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="org.test.launchtest" />

A: 

Hmm I wasn't able to do the trick with host too. Hence I ended up with using more specific scheme.

<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="com.stackoverflow.example" />
</intent-filter>

Probably you may use scheme solution too?

Konstantin Burov
How did you open that activity, by entering com.stackoverflow.example:// in the browser? I tried this and again, nothing. It just runs a query of the text.
jaredbro
I wasn't able to do the trick with manually entering an adsress in browser. But it works perfectly if you click a link with the scheme or starting an Intent manually providing Uri starting with the scheme.At http://stack-examples.appspot.com/ you can see the example link which works for The Presidents app :) http://www.cyrket.com/p/android/com.socratica.mobile.presidents/ You can try installing the app and then clicking the link in browser.
Konstantin Burov