1

I know this has been asked before, and I have looked through a lot of those questions, but none seems to hold the answer for me. What I am trying to do is to open my app when I click a link, which in my case would look like dots://test.com/. I'm trying to get this working through intents. When I replace dots:// with http:// and use http in my scheme instead of dots, it works fine. But since the only domains I own have got pretty long urls, it's not practical to go that route. My android manifest looks like this:

<application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:logo="@drawable/logo"
        android:theme="@style/AppTheme" >
        <meta-data
            android:name="com.google.android.gms.version"
            android:value="@integer/google_play_services_version" />
        <meta-data
            android:name="ADMOB_ALLOW_LOCATION_FOR_ADS"
            android:value="true" />

        <activity
            android:name="nl.delta6.dots.engine.MainActivity"
            android:exported="true"
            android:label="@string/app_name"
            android:screenOrientation="landscape"
            android:theme="@android:style/Theme.NoTitleBar.Fullscreen" >
            <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="dots" />
            </intent-filter>
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity
            android:name="com.google.android.gms.ads.AdActivity"
            android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize" />
</application>

I have tried numerous solutions mentioned in posts like Make a link in the Android browser start up my app? and Launch android application from a browser link, but none seem to work for me. All ideas are welcome.

Edit 1: Okay, so I noticed that if I click a link on a webpage like dots link, it does launch my app. The links just don't show as links in other apps, though I know that is possible. I'll keep looking around, but if there's anybody who could send me off in the right direction that'd be more than welcome.

Community
  • 1
  • 1
TSC
  • 31
  • 8

1 Answers1

0

I think the best article is here: Make a link in the Android browser start up my app?

Note that you really want to use hackbod's recommendation, which means that registering the scheme "dots" to yourself is not a good idea. The easiest way to create a link that a browser can use is to first, in a test setting, have your intent format itself to a uri:

Intent intent = new Intent(someContext, MainActivity.class)
System.out.println[or use logcat](intent.getUri());

Then just paste the output from intent.getUri() as a url. It will look something like:

intent:#Intent;component=[your/activty/class/NameActivity;]

If you serve that as a link on a website, connect to it on your phone with your app installed and click the link it should then open your app.

Note that you can also add "extras" to your activity using putExtra if you want to see example intent uris that can be used to send extra data back to your app.