【问题标题】:Launching another application using custom URL scheme opens the application within the boundaries of the launching application.使用自定义 URL 方案启动另一个应用程序会在启动应用程序的边界内打开该应用程序。
【发布时间】:2016-01-13 09:47:05
【问题描述】:

我在帖子里看到How to open an application inside another application within the latters boundaries in android?

但是当我尝试使用自定义 URL 方案打开另一个应用程序时,我的应用程序正在发生这种情况。有谁知道为什么会发生这种情况?

调用其他应用的代码如下。

String callBackUrl = “OtherApp://result?params”; // This is supposed to be a callback URL with query parameters
String redirectUrl = callBackUrl.substring(0, callBackUrl.indexOf("://"));
Intent redirectIntent = new Intent();
redirectIntent.putExtra(Intent.EXTRA_TEXT, callBackUrl);
redirectIntent.setAction(redirectUrl);
redirectIntent.setType("text/plain");
startActivity(redirectIntent);

【问题讨论】:

    标签: android callback intentfilter url-scheme custom-url


    【解决方案1】:

    原因是,我的应用程序是单任务应用程序。它是我的活动元素的 AndroidManifest.xml 中的 android 属性。

            android:launchMode="singleTask"
    

    我找到的解决方案是在“redirectIntent”中添加两个标志。

            redirectIntent.setFlags(Intent.URI_INTENT_SCHEME);
            redirectIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-12-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多