【问题标题】:Intent Filter passing data through url and reading into activity意图过滤器通过 url 传递数据并读入活动
【发布时间】:2016-01-27 13:04:36
【问题描述】:

在我的应用程序中,我需要通过电子邮件中的链接从外部应用程序打开一个页面。

在我的应用程序中,当有人会从我们的网站创建帖子时,我们会发送带有 url 的电子邮件。

当用户点击url/link时,它将在应用程序中打开相应的页面。

我需要在活动启动时将一些 id 和其他值传递给活动。

例子:

当有人在网站上创建帖子时,我们会通过电子邮件发送以下链接。

https://www.example.com/lt-url-redirector.php?user_guid=4074395&notify_entity_id=7221752&notification_type=22&notify_id=56933b6219b05172&baseurl=https://www.example.com/groups/calendar/aggregation/mlt

点击上面的链接后,它会转到有“在应用程序中打开”按钮的移动浏览器。

点击此按钮后,它会给出:

window.location.href = 'abcdef:/?user_guid=4074395&notify_entity_id=7221752&notification_type=22&notify_id=56933b6219b05172&baseurl=https://www.example.com/groups/calendar/aggregation/mlt';

我想在活动启动时将 notify_entity_id、notification_type、notify_id 等传递给活动。

Android 清单代码:

<intent-filter>
            <data android:scheme="abcdef" />

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

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

【问题讨论】:

  • Stack Overflow 用于编程问题。你有什么问题?
  • 我的问题是如何将数据href(单击浏览器按钮时)读取到此按钮打开的活动中。

标签: android android-layout android-intent intentfilter


【解决方案1】:

这些是查询参数,Uri 上有多种方法可以检索这些值,such as getQueryParameters()。要获取Uri,请从某个可能的位置致电getIntent().getData(),例如您的活动的onCreate()

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-02-05
    • 1970-01-01
    • 1970-01-01
    • 2022-12-09
    • 1970-01-01
    • 2018-01-18
    • 2018-09-11
    相关资源
    最近更新 更多