I use this in manifest.xml:
<activity android:name=".SomeName"> <intent-filter> <category android:name="android.intent.category.ALTERNATIVE" /> <action android:name="android.intent.action.VIEW" /> <category android:name="android.intent.category.DEFAULT" /> <category android:name="android.intent.category.BROWSABLE" /> <data android:host="google.com" android:scheme="http" /> </intent-filter> </activity>
This will launch Activity SomeName. I do not use www in android: the host part might matter.
When the action begins, you can get the data that is behind .com using (for example):
Uri data = getIntent().getData(); if(data != null && data.getPathSegments().size() >= 2){ List<String> params = data.getPathSegments(); String somestuff = params.get(0); }
Edit: if you cannot verify the host inside the action, use this method:
data.getHost();
source share