【问题标题】:Redirect url to app android将 url 重定向到应用程序 android
【发布时间】:2017-08-25 09:37:16
【问题描述】:

我希望 oauth2 身份验证的回调重定向到我的应用程序。我知道 chrome 的意图过滤器,但它需要用户手动要求应用程序打开。我在互联网上读到不可能自动执行此操作,但 Instagram 甚至 Google 的 IO 应用程序等应用程序都可以从浏览器打开(这里有一些示例 https://instagram.com/_u/instagramhttps://events.google.com/io/schedule)。我也尝试过意图过滤器(在清单中),但它们也不起作用。我不要求应用程序由 oauth 中的回调 url 触发,如果需要我可以使用后端。我如何做到这一点?

【问题讨论】:

标签: java android intentfilter


【解决方案1】:

你需要什么 深度链接。要在链接点击时打开您的应用,您需要在清单中添加 Intent Filer“android.intent.action.VIEW”。

 <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="example.com"
                android:pathPrefix="/api/v1/view"
                android:scheme="http" />
        </intent-filter>

一旦您建立了与清单中提到的具有相同签名的链接,android 系统将在选择器中添加您的应用程序以在您的应用程序中打开链接,您将在相应的 Activity 中获取“getIntent().getData()”中的数据。

如果未安装应用程序,链接将在浏览器中打开。然后在浏览器中处理。

要从浏览器发送意图,您需要遵循与清单相同的架构。

"intent://example.com/api/v1/view#Intent;scheme=http;package=com.app;category=android.intent.category.BROWSABLE;component=com.app.yourActivityname;action=android.intent.action.VIEW;end

【讨论】:

  • 我已经尝试了这两种解决方案。第一个不起作用,第二个需要用户请求打开应用程序
猜你喜欢
  • 1970-01-01
  • 2019-11-24
  • 1970-01-01
  • 1970-01-01
  • 2021-08-07
  • 2012-08-25
  • 1970-01-01
  • 1970-01-01
  • 2013-03-15
相关资源
最近更新 更多