Consider you are an Android application developer. You created a mobile application for your website and you would like to enable your users to browse content of your website using a mobile app. It’s easy if a website uses RESTful guidelines for creating URLs. Problem comes when a website uses SEO friendly URLs. Handling such links is hard because regular expression mechanism in Android manifest is flawed.

Suppose you want to support links in such format:{product-id}-{product-name-and-product-description}.html

In AndroidManifest.xml you define:

<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=""
          android:scheme="http" />

Pretty easy, huh?

But let’s say that we want to handle links in the following format:{friendly-yet-changing-title}-t{product-id}.html

Using android:pathPattern attribute won’t help since it has very limited functionality and can’t handle more complex patterns.


Slinger was created to address such situations.

Slinger is a simple library that captures all the links within a domain and redirects them to corresponding parts of mobile application.

Here is conceptual diagram that shows how Slinger works:

![Diagram explaining how Slinger works](/img/articles/2015-07-31-slinger-diagram.png)


As a Slinger user you need to create thin Activity handling all URLs used by website and provide regular expressions with corresponding Intent that launch specific part of your application.

At the beginning you declare Activity that will be handling all URLs within your domain:

<activity android:name="com.example.MySlingerRoutingActivity ">
        <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:pathPattern="/.*" />

Then you create appropriate rules that redirect URL to concrete Activity:


public class MySlingerRoutingActivity extends SlingerActivity {


    private RedirectRule getRedirectRuleForProductActivity() {
        return RedirectRule.builder()
            .intent(new Intent(context, MyConcreteActivityForProduct.class))

    @Override protected IntentResolver getIntentResolver() {
        return new IntentResolver(asList(getRedirectRuleForProductActivity()));

You can provide as many RedirectRules as you wish. When URL doesn’t match any rule, a default intent is launched.


If your website has friendly urls and you are tired of limitations of intent filters then try Slinger!