Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android App Intent Filter sometimes not working

For a project I have encountered a very strange issue:

Deeplinks have been working very well for the last year, but recently (since the beginning of January-2019) we have been getting complaints from our users that deeplinks have stopped working (some say 9 out of 10 time).

We have not changed any of this code and have great difficulty reproducing this issue.

Even stranger, in the sparse times that we do encounter the issue ourselves, the android OS does not even show our app as an option through the 'open with'-dialog. This suggest to us that the OS sometimes forgets that the app has intent-filters registered in its Manifest.

Restarting the app appears to fix this and deeplinks start working again. The app also seems to work every time we do a new build from Android Studio, which makes it very hard to reproduce.

Our manifest has a specific activity that handles deeplinks:

<activity
    android:name="com.company.DeepLinkActivity"
    android:noHistory="true"
    android:launchMode="singleTask">
    <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:host="ideal-payment"
            android:scheme="com.company.ideal" />
        <data
            android:host="ideal-payment"
            android:scheme="com-company-ideal" />

    </intent-filter>

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

        <data
            android:host="${appLinkIdealHost}"
            android:pathPrefix="/ideal-betaling/landingpage"
            android:scheme="https" />
    </intent-filter>

    <intent-filter android:autoVerify="true">
        ...
    </intent-filter>

    <intent-filter android:autoVerify="true">
        ...
    </intent-filter>
</activity>

We thought it might have something to do with the autoVerify not being accessible, but then the OS should show the 'open with'-dialog, which does not happen when the issue surfaces.

Is there someone that has encountered a similar issue? Any help or suggestions would be greatly appreciated.

like image 666
Spoetnic Avatar asked Mar 05 '19 14:03

Spoetnic


1 Answers

When app is stopped for example with an exception or when user have force stopped it from settings or in some devices when user removes app from history (or from tasks) the app will be force stopped automatically (which is not a good choice from manufacturer) when app is in stopped state its manifest intentFilter will not be used (when app is first installed and never opened also it is in this phase)

While in stopped state, the application will not run for any reason, except by a manual launch of an activity, or an explicit intent that addresses an activity ,service or broadcast.

https://riptutorial.com/android/example/30592/android-stopped-state


Most of Android versions you mentioned was 8 or grater thus below quotation also may be useful but this is for services and broadcast receivers.

Whenever an app runs in the background, it consumes some of the device's limited resources, like RAM. This can result in an impaired user experience, especially if the user is using a resource-intensive app, such as playing a game or watching video. To improve the user experience, Android 8.0 (API level 26) imposes limitations on what apps can do while running in the background.

https://developer.android.com/about/versions/oreo/background

like image 113
ygngy Avatar answered Sep 27 '22 18:09

ygngy