Android:使用 Intent Url 方案显式调用 Activity

标签 android android-intent url-scheme

我正在尝试了解 Intent URL's 在 android 中是如何工作的。我知道我可以隐式调用在 AndroidManifest 文件中设置了 intent-filter 的 Activity 。但据我所知,我们可以调用在 AndroidManifest 中没有设置 intent-filter 的应用程序 Activity 。我尝试了一些案例,但无法实现。我编写了一个包含一些 Activity 的简单应用程序(没有 intent-filter),但我无法使用 Intent URL 运行它们。而且我在互联网(和 stackoverflow)中找不到任何关于 explicit intent url 的有用示例。

因此,如果有人可以为使用 intent url 的显式 Activity 调用 提供一个简单的示例或一个简短的解释,我将不胜感激。

问候,
穆罕默德

最佳答案

这个答案有点晚了,但为了将来引用,我认为 Intent Url 你的意思是你的 Intent 的 Uri

很容易找到 Uri任何 Intent (显式或隐式)的格式只需声明一个 Intent在 java 中使用这些参数对象,然后调用 toUri为您提供该 Intent 的字符串格式的方法。然后,您可以在您的网页中使用它来与您的应用进行通信。

Intent intent = new Intent(this, SomeActivity.class);
String intentUri = intent.toUri(0);

关于Android:使用 Intent Url 方案显式调用 Activity,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39540111/

相关文章:

android - 使用绑定(bind)膨胀布局时出现 MVVMCross 异常

java - 如何在一个字符串中存储多个单词而不替换java中的旧单词

android - 如何在android中将位图设置为intent

python - 为什么 urllib.parse 不分割 URL <scheme> :<number> correctly in all cases?

android - 默认 Android Studio 抽屉导航 Activity 模板不显示汉堡包图标,仅显示箭头图标

java - Android动态添加自定义组件到LinearLayout

android - ShareCompat.IntentBuilder : Intent. 数据与收件人混合

ios - 为什么我们需要 "URL Identifier"(CFBundleURLName) plist 字段才能在 iOS 上使用自定义 URL 方案?

java - WAR 文件部署到 Tomcat 失败 : URI scheme error

android统计每个APP的3g流量,怎么样?