【问题标题】:Support opening App from Browser支持从浏览器打开应用
【发布时间】:2014-08-21 09:28:57
【问题描述】:

我的网页有以下链接:

myapp://www.myapp.com/xxxxxx

所需的效果是当从 Android 设备上的浏览器单击此链接时, 它应该将“myapp”检测为自定义协议,如果已安装,则直接在设备上打开 MyApp。

Launching custom Android application from Android browser / Chrome

Launch custom android application from android browser

我已经研究过这个主题,并在下面发现了与这个问题类似的问题,

他们提到在 AndroidManifest.xml 中编辑部分,但他们没有解决问题。

关键是浏览器似乎无法将 MyApp 识别为自定义协议。

【问题讨论】:

  • 请粘贴您的清单/您尝试添加查看操作意图过滤器以捕获这些意图。
  • 请注意,上面的意图过滤器似乎将 HTTP 调用“cybeye.com”定向到 CybEye 应用程序。但我想要的是定义一个自定义协议“cybeye://xxx”,并且只有使用这种协议的链接(不是所有 HTTP 调用)才会被定向到应用程序。

标签: android protocols manifest intentfilter


【解决方案1】:

如果您希望链接重定向到您手机上的应用:使用格式为:

android-app::\\<package name>\<URI segments>

在手机上,它会被解析成一个URI发送到你的包(app)。在您的应用中,您需要做的就是处理这些意图。

当您的应用收到它时,应使用 ACTION_VIEW 意图过滤器来解析以下 URI:

intent:\\<URI segments>

intent 是你的计划。只需执行以下操作即可。

<intent-filter> <action android:name="android.intent.action.VIEW" /> <data android:scheme="intent" /> <category android:name="android.intent.category.DEFAULT"/> <category android:name="android.intent.category.BROWSABLE" /> </intent-filter>

对于通过浏览器在网络应用或移动应用上用作登录页面的其他链接: http://www.myapp.com/xxx/yyyy

<data android:host="www.myapp/com" android:scheme="http" android:pathPrefix="xxx />

【讨论】:

  • 1.假设应用程序名称 = 'MYAPP'。 2.链接可以是MYAPP:\\xxxxx 3.Manifest添加 这行得通吗?
  • 我猜#2中的更正:而不是“MYAPP:\\xxxx”使用“android-app:\\MYAPP\xxxx”?
猜你喜欢
  • 2013-08-17
  • 1970-01-01
  • 2019-04-12
  • 1970-01-01
  • 1970-01-01
  • 2011-03-20
  • 2019-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多