Name: slinger
Owner: Allegro Tech
Description: Slinger - deep linking library for Android
Created: 2015-08-21 13:56:40.0
Updated: 2017-11-15 13:47:33.0
Pushed: 2016-05-16 14:53:48.0
Size: 222
Language: Java
GitHub Committers
User | Most Recent Commit | # Commits |
---|
Other Committers
User | Most Recent Commit | # Commits |
---|
Slinger is a small Android library for handling custom Uri which uses regular expression to catch and route URLs which won?t be handled by normal intent-filter mechanism.
With slinger it?s possible to provide deep links for quite complicated URLs.
Declare Activity in your manifest with your own IntentResolver
that will handle links within particular domain.
ivity
droid:name="pl.allegro.android.slinger.SlingerActivity"
droid:excludeFromRecents="true"
droid:noHistory="true"
droid:theme="@style/android:Theme.NoDisplay">
eta-data
android:name="IntentResolver"
android:value="com.my.appp.ExampleIntentResolver"/>
<intent-filter android:label="@string/app_name">
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.DEFAULT"/>
<category android:name="android.intent.category.BROWSABLE"/>
<data
android:host="example.com"
android:pathPattern="/.*"
android:scheme="http"/>
</intent-filter>
tivity>
IntentResolver
is a class that redirects URLs to concrete Activities based on regular expressions.
p
ic class ExampleIntentResolver extends IntentResolver {
ivate List<RedirectRule> rules;
blic ExampleIntentResolver(Activity activity) {
super(activity);
rules = asList(getRedirectRuleForAboutActivity(activity));
ivate RedirectRule getRedirectRuleForAboutActivity(Activity activity) {
return RedirectRule.builder()
.intent(new Intent(activity, MyConcreteActivityA.class))
.pattern("http://example.com/abc\\\\.html\\\\?query=a.*")
.build();
onNull @Override public Iterable<RedirectRule> getRules() {
return rules;
In case when no redirect rule is matched IntentResolver
will fallback to default Intent - Uri
with ACTION_VIEW
.
In order to provide other mechanism than regular expression matching you can override resolveIntentToSling
in IntentResolver
Slinger enriches Intents with URL and referrer by default.
This can be changed by overriding enrichIntent
in IntentResolver
p
ic class ExampleIntentResolver extends IntentResolver {
onNull
verride
blic Intent resolveIntentToSling(@NonNull Uri originatingUri) {
// implement own intent resolving strategy here
return super.resolveIntentToSling(originatingUri);
verride
blic Intent enrichIntent(Activity parentActivity, Intent resolvedIntent, Uri originatingUri) {
// enrich resolved intent with custom data
return super.enrichIntent(parentActivity, resolvedIntent, originatingUri).putExtra("foo","bar");
Slinger does not sanitize input in any way. So providing security for application is your responsibility.
slinger is published under Apache License 2.0.