Skip to content

Instantly share code, notes, and snippets.

@jschmid
Created February 5, 2013 10:53
Show Gist options
  • Save jschmid/4713706 to your computer and use it in GitHub Desktop.
Save jschmid/4713706 to your computer and use it in GitHub Desktop.
Android Activity with a custom protocol
// In the onCreate()
Intent intent = getIntent();
if (Intent.ACTION_VIEW.equals(intent.getAction())) {
Uri uri = intent.getData();
Log.i(TAG, "Started by a user clicking " + urlStr);
doSomethingWithTheUrl(uri.toString(););
}
<activity android:name=".MyActivity" android:label="@string/app_name">
<!-- open the app when a foo://www.example.com link is clicked -->
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.BROWSABLE" />
<category android:name="android.intent.category.DEFAULT" />
<data android:scheme="foo" />
</intent-filter>
</activity>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment