是否可以建立如下链接:
<a href="anton://useful_info_for_anton_app">click me!</a>
Run Code Online (Sandbox Code Playgroud)
导致我的Anton应用程序启动?
我知道这适用于具有市场协议的Android Market应用程序,但是可以与其他应用程序类似吗?
以下是启动Android电子市场的链接示例:
<a href="market://search?q=pname:com.nytimes.android">click me!</a>
Run Code Online (Sandbox Code Playgroud)
更新:
我接受eldarerat提供的答案很有用,但我只想提一下,我对<intent-filter>标签的子元素的顺序有些麻烦.我建议您只<intent-filter>使用该标签中的新子元素制作另一个,以避免我遇到的问题.例如我AndroidManifest.xml看起来像这样:
<activity android:name=".AntonWorld"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<data android:scheme="anton" />
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.BROWSABLE" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
Run Code Online (Sandbox Code Playgroud) 我正在使用Ionic Framework(基于Cordova)开发移动应用程序.
在Android中,我注册我的应用程序以打开*.txt文件.我在平台/ android/AndroidManifest.xml中添加了intent-filter,它可以工作.但是平台文件夹在.gitignore中:我想用config.xml来做.
我尝试在config.xml中添加:
<platform name="android">
<config-file target="AndroidManifest.xml" parent="/*/application/activity">
<intent-filter><!-- ... --></intent-filter>
</config-file>
<!-- ... -->
</platform>
Run Code Online (Sandbox Code Playgroud)
我还尝试添加:
<platform name="android">
<config-file target="AndroidManifest.xml" parent="/manifest/application">
<activity android:name="CordovaApp">
<intent-filter><!-- ... --></intent-filter>
</activity>
</config-file>
<!-- ... -->
</platform>
Run Code Online (Sandbox Code Playgroud)
然后我尝试更新AndroidManifest启动
ionic prepare
Run Code Online (Sandbox Code Playgroud)
或者:
ionic remove platform android && ionic add platform android
Run Code Online (Sandbox Code Playgroud)
但AndroidManifest.xml始终保持不变.我究竟做错了什么?
我正在使用Ionic 1.3.2和Cordova 4.2.0.
在这里编辑整个config.xml:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<widget id="com.ionicframework.myapp551932" version="0.0.1" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0" xmlns:android="http://schemas.android.com/apk/res/android">
<name>MyApp</name>
<description>
myApp
</description>
<author email="xxx@yyy.it" href="http://www.example.com/">
A Team
</author>
<content src="index.html"/>
<access origin="*"/>
<preference …Run Code Online (Sandbox Code Playgroud) 我一直试图通过电子邮件链接或某些社交网站上的帖子启动应用程序.问题是在android上的某些设备或某些gmail应用程序中没有显示我指定的锚标签或链接.
在intent-filter下面,我设置为我的行为是:
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="myappname" />
Run Code Online (Sandbox Code Playgroud)
我正在发送带有此锚标记的电子邮件
myappname://processtobedone/?id=1
Run Code Online (Sandbox Code Playgroud)
它适用于我在华为设备上的电子邮件应用程序,但在设备的默认gmail应用程序中,它没有显示它有链接,并且在某些设备中默认情况下它附加https:作为标签的后缀并启动浏览器.