Question

In IOS I have 2 apps (App A and App B) that will be performing different objective but at 1 point, App A will call App B using uri scheme to perform a function where App A does not have.

I wanted to implement this function to Android and currently have developed a demo for initiating call to App B. Now I am working on App B that will be receiving the uri scheme from the demo app.

Problem:

After App B return to the demo app using uri scheme I close the demo app. When I go back to home page and open the multitask to reopen App B(or open App B through the icon), the page it reopen is the function that is used for demo app but what I wanted is the login page of App B.

This is a part of the Manifest for the intent-filter

<activity
        android:name="com.apps.MasterActivity"
        android:label="@string/app_name"
        android:screenOrientation="portrait"
        android:clearTaskOnLaunch="true"
        android:windowSoftInputMode="adjustPan" >

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

        <category android:name="android.intent.category.LAUNCHER" />
    </intent-filter>
    <intent-filter>
        <data
             android:host="x-callback-url"
             android:scheme="myapp" />

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

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

This is where I call back to the demo app

Intent sendIntent = new Intent(Intent.ACTION_VIEW, responseUri);
sendIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
finish();
startActivity(sendIntent);
Was it helpful?

Solution 2

Apparently I kinda found a solution that can force the app to show the login page after going back to the demo app. By putting this code in the activity.java file.

@SuppressWarnings("deprecation")
@Override
public void onDestroy()
{
    super.onDestroy();
    System.runFinalizersOnExit(true);
    System.exit(0);
}

I know its a deprecated function that I'm using but will try to solve it when there's something wrong in the future or when I found a better solution for it.

Edit: Found a better solution that does not need to use the deprecated function which I have forgotten to set it to false.

I have a flag that is set to true when the app is connected through Uri Scheme which i just have to set it to false and it will be fixed. This is the change location that I made

Intent sendIntent = new Intent(Intent.ACTION_VIEW, responseUri);
sendIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
finish();
startActivity(sendIntent);
Util.isUriScheme = false;

OTHER TIPS

Try adding this to your activity tag in AndroidManifest.xml

android:clearTaskOnLaunch="true"
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top