Declaring an arbitrary url scheme in the manifest, resulting in duplicate application in the full action dialog

I want to open a deep link dialog in my application, so I have defined the following in my manifest:

<activity
    android:name=".ActivityA"
    android:screenOrientation="portrait"
    android:theme="@style/AppBaseTheme"
    android:windowSoftInputMode="stateHidden|stateVisible" >
    <intent-filter>
        <data android:scheme="rentaldashboard" />
        <data android:scheme="https" />
        <data android:scheme="http" />
        <data android:host="my.site.com" />

        <data android:pathPattern=".*" />

        <category android:name="android.intent.category.DEFAULT" />
        <category android:name="android.intent.category.BROWSABLE" />

        <action android:name="android.intent.action.VIEW" />
    </intent-filter>

      

    <activity
    android:name=".ActitivtyB"
    android:screenOrientation="portrait"
    android:theme="@style/AppBaseTheme"
    android:windowSoftInputMode="stateHidden|stateVisible" >
    <intent-filter>
        <data android:scheme="rentalreset" />
        <data android:scheme="https" />
        <data android:scheme="http" />
        <data android:host="my.site.com" />

        <data android:pathPattern=".*" />

        <category android:name="android.intent.category.DEFAULT" />
        <category android:name="android.intent.category.BROWSABLE" />

        <action android:name="android.intent.action.VIEW" />
    </intent-filter>
</activity>

      

ActivityA and ActivityB use a schema and when I run over the code it shows a dialog like below:

Complete action with

The dialog shows my application logo twice. I want only one logo to be displayed at a time for both activities. So, any idea how I can make this possible?

+3


source to share


1 answer


If you only have partial urls like /user

or /news

for ActivityA and /admin

it's just for ActivityB then you should improve your path filters. By the way, they have to start with a forward slash and that the patterns are not regexps.

If you want to support custom schema and http (s) url, then you should use several intent filters:



<activity
    android:name=".ActivityA"
    android:screenOrientation="portrait"
    android:theme="@style/AppBaseTheme"
    android:windowSoftInputMode="stateHidden|stateVisible" >
    <intent-filter>
        <data android:scheme="https" />
        <data android:scheme="http" />
        <data android:host="dev.worldofrental.com" />
        <data android:host="www.worldofrental.com" />

        <data android:pathPrefix="/urlredirect/getstarted" />

        <category android:name="android.intent.category.DEFAULT" />
        <category android:name="android.intent.category.BROWSABLE" />
        <action android:name="android.intent.action.VIEW" />
    </intent-filter>
    <intent-filter>
        <data android:scheme="your.package.name"
              android:host="getstarted" />

        <category android:name="android.intent.category.DEFAULT" />
        <category android:name="android.intent.category.BROWSABLE" />
        <action android:name="android.intent.action.VIEW" />
    </intent-filter>
</activity>

<activity
    android:name=".ActitivtyB"
    android:screenOrientation="portrait"
    android:theme="@style/AppBaseTheme"
    android:windowSoftInputMode="stateHidden|stateVisible" >
    <intent-filter>
        <data android:scheme="https" />
        <data android:scheme="http" />
        <data android:host="dev.worldofrental.com" />
        <data android:host="www.worldofrental.com" />

        <data android:pathPrefix="/urlredirect/resetpassword" />

        <category android:name="android.intent.category.DEFAULT" />
        <category android:name="android.intent.category.BROWSABLE" />
        <action android:name="android.intent.action.VIEW" />
    </intent-filter>
    <intent-filter>
        <data android:scheme="your.package.name"
              android:host="resetpassword" />

        <category android:name="android.intent.category.DEFAULT" />
        <category android:name="android.intent.category.BROWSABLE" />
        <action android:name="android.intent.action.VIEW" />
    </intent-filter>
</activity>

      

In general, I would suggest using the package name as the schema to make sure no other application will steal your intent.

+1


source







All Articles