【发布时间】: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