【问题标题】:Android receiver not called with data/host intent filter未使用数据/主机意图过滤器调用 Android 接收器
【发布时间】:2021-11-25 00:35:44
【问题描述】:

我在Android Manifest 中声明了一个接收者

<receiver
        android:name=".receiver.ConnectionReceiver"
        android:exported="true">

        <intent-filter>

            <data
                android:host="login"
                android:scheme="tisseo.main" />

        </intent-filter>
    </receiver>

我关联了这个接收器类:

class ConnectionReceiver : BroadcastReceiver() {
    override fun onReceive(context: Context?, intent: Intent?) {

        Log.d("ConnectionReceiver", "Mais lol")

        StringBuilder().apply {
            append("Action: ${intent?.action}\n")
            append("URI: ${intent?.toUri(Intent.URI_INTENT_SCHEME)}\n")
            toString().also { log ->
                Log.d("ConnectionReceiver", log)
                Toast.makeText(context, log, Toast.LENGTH_LONG).show()
            }
        }
    }
}

我有这个带有这个链接的 HTML 页面:

<a class="submit lienButton" name="login" type="submit" href="tisseo.main://login">LOG IN</a>

当我点击它时,没有任何附加内容。即使我的应用程序是否启动。

但是,如果我将 Intent 过滤器放入活动中,当我单击 HTML 链接时,我的活动就会启动。

那么,我可以做些什么来使用我的意图过滤器主机/方案调用我的接收器。

非常感谢

【问题讨论】:

    标签: android android-intent android-manifest receiver


    【解决方案1】:

    我可以做些什么来使用我的意图过滤器主机/方案调用我的接收器

    这是不可能的,除非强制每个 Web 浏览器开发人员更改他们的应用程序。链接和类似功能通过 ACTION_VIEW Intent 打开活动——它们不发送广播。

    【讨论】:

      猜你喜欢
      • 2015-05-01
      • 1970-01-01
      • 1970-01-01
      • 2016-11-06
      • 2011-02-09
      • 1970-01-01
      • 2021-11-30
      • 2014-12-20
      • 2015-05-14
      相关资源
      最近更新 更多