Java Android应用程序在使用uri方案后打开错误页面

Java Android应用程序在使用uri方案后打开错误页面,java,android,uri-scheme,Java,Android,Uri Scheme,在IOS中,我有两个应用程序(应用程序A和应用程序B)将执行不同的目标,但在1点上,应用程序A将使用uri方案调用应用程序B,以执行应用程序A没有的功能 我想在Android上实现这个功能,目前已经开发了一个用于启动对应用程序B的调用的演示。现在我正在开发应用程序B,它将从演示应用程序接收uri方案 问题: 在应用程序B使用uri方案返回演示应用程序后,我关闭演示应用程序。 当我返回主页并打开多任务以重新打开应用程序B(或通过图标打开应用程序B)时,它重新打开的页面是用于演示应用程序的功能,但我

在IOS中,我有两个应用程序(应用程序A和应用程序B)将执行不同的目标,但在1点上,应用程序A将使用uri方案调用应用程序B,以执行应用程序A没有的功能

我想在Android上实现这个功能,目前已经开发了一个用于启动对应用程序B的调用的演示。现在我正在开发应用程序B,它将从演示应用程序接收uri方案

问题:

在应用程序B使用uri方案返回演示应用程序后,我关闭演示应用程序。 当我返回主页并打开多任务以重新打开应用程序B(或通过图标打开应用程序B)时,它重新打开的页面是用于演示应用程序的功能,但我想要的是应用程序B的登录页面

这是意图过滤器清单的一部分

<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>

尝试将其添加到AndroidManifest.xml中的活动标记中

android:clearTaskOnLaunch="true"

显然,我找到了一个解决方案,可以强制应用程序在返回演示应用程序后显示登录页面。将此代码放在activity.java文件中

@SuppressWarnings("deprecation")
@Override
public void onDestroy()
{
    super.onDestroy();
    System.runFinalizersOnExit(true);
    System.exit(0);
}
我知道我正在使用一个不推荐使用的函数,但当将来出现问题或我找到更好的解决方案时,我会尝试解决它

编辑: 找到了一个更好的解决方案,它不需要使用我忘记将其设置为false的弃用函数

当应用程序通过Uri方案连接时,我有一个设置为true的标志,我只需将其设置为false,它就会被修复。这是我更改的位置

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

添加后,该行仍然相同
Intent sendIntent = new Intent(Intent.ACTION_VIEW, responseUri);
sendIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
finish();
startActivity(sendIntent);
Util.isUriScheme = false;