是否可以建立如下链接:
<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) 假设我想定义一个URI,例如:
myapp://path/to/what/i/want?d=This%20is%20a%20test
Run Code Online (Sandbox Code Playgroud)
必须由我自己的应用程序或服务处理.请注意,该方案"myapp",而不是"http",或"ftp".这正是我的意图:为Android OS全局定义自己的URI架构.这可能吗?
这有点类似于某些程序已经在做的事情,例如Windows系统,例如Skype(skype://)或任何torrent下载程序(torrent://).
我希望在用户访问某个网址时启动我的意图:例如,Android市场通过http://market.android.com/网址进行此操作.youtube也是如此.我也希望我也这样做.
您如何为Flutter应用添加启动画面?它应该在任何其他内容之前加载和显示.目前,在Scaffold(home:X)小部件加载之前,会有一个短暂的颜色闪烁.
我正在尝试使用此SO问题作为参考从URI启动Android应用程序.
我有一个清单文件,其中包含以下声明的活动:
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<data android:scheme="http" android:host="example.com" />
</intent-filter>
</activity>
Run Code Online (Sandbox Code Playgroud)
我正在尝试使用http://example.com链接启动MainActivity .我的问题是我得到了警告
"exported activity does not require permission"
Run Code Online (Sandbox Code Playgroud)
我已经查看了报告此相同警告的其他SO问题,并且所有解决方案似乎都不起作用.
如何正确编写活动intent-filter以避免警告?
谢谢
我有一个Android应用程序,人们用它来替代网站.因此,当用户遇到网站的URL时,我想让他们在我的应用程序中而不是在浏览器中"打开URL".换句话说,我希望弹出窗口可以让我们在我的应用程序和浏览器(以及可能的其他应用程序)之间进行选择.
我从各种渠道了解到,我需要在我的应用中为活动添加一个意图过滤器,其中"数据"过滤器会过滤正确形式的网址.
有问题的网站是http://members.iracing.com,因此我添加了以下intent过滤器:
<activity
android:name=".MainActivity"
android:label="@string/title_activity_main" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<data android:scheme="http" />
<data android:host="members.iracing.com" />
</intent-filter>
</activity>
Run Code Online (Sandbox Code Playgroud)
我尝试了各种形式的这些数据过滤器,例如使用具有这两个属性的单个"数据"节点:
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<data android:scheme="http" android:host="members.iracing.com"/>
</intent-filter>
Run Code Online (Sandbox Code Playgroud)
它根本不起作用.我不知道还能告诉你什么.我在我的网站上托管了一个简单的HTML页面,其中有几个链接指向该网站上的各个页面(所有页面都以"http://members.iracing.com/..."开头),当我点击其中任何页面时,它们只是打开在浏览器中没有问我想要使用哪个应用程序.我在模拟器上以及在我的物理设备上安装应用程序后都尝试了它,没有任何作用.我在一个完全BLANK,新的Android项目中尝试了这个,只是为了看看它是否有用,什么都没有.
然后我意识到该网站需要身份验证,如果您没有登录,则会重定向到https://members.iracing.com/membersite/login.jsp上的登录页面,因此我尝试用"https"替换该方案.我甚至尝试将主机改为"www.members.iracing.com",最后我甚至尝试了所有这些东西的组合(不确定这是否应该有效,但是嘿,我现在绝望了...... ...)
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<data android:scheme="http" />
<data android:scheme="https" />
<data android:host="members.iracing.com" />
<data android:host="www.members.iracing.com" />
</intent-filter>
Run Code Online (Sandbox Code Playgroud)
仍然没有去.我不确定重定向是否相关,浏览器显然首先进入非重定向网站,然后重定向到登录页面,但在任何时候我都无法选择在我的应用程序中打开它.此外,如果我首先在浏览器中手动登录,则没有重定向,但仍然无效.
我错过了一些明显的东西吗?我把我的头发拉出来为什么这不起作用,除了尝试我能想到的每一种可能的组合之外我都无法调试它(我做了......).谢谢你的帮助!
总结我有一个具有正确功能的URL方案的应用程序,我想从主屏幕上存储的Web应用程序启动,而普通的JavaScript重定向方法似乎不起作用.
详细信息我正在尝试创建一个iOS网络应用程序,从主屏幕上保存的链接以全屏模式打开.Web应用程序需要打开特定的本机应用程序.我已经为本机应用程序注册了url方案,并验证它是否正常工作 - 例如,我可以通过直接在我的Safari地址栏中键入方案来打开本机应用程序.我也可以使用+openURL:方法从其他应用程序打开它UIApplication.我还想用可以添加到主屏幕的本机Web应用程序中的某些参数打开它.
我想要做的是在本机应用程序中使用这样的JavaScript:
window.location = "myapp://myparam";
Run Code Online (Sandbox Code Playgroud)
在Web应用程序中使用此代码时,我会收到一条提示:
"无法打开myWebAppName - 无法打开myWebAppName.错误是"此URL无法显示"."
在Safari中执行时,这个相同的JavaScript工作正常.我得到了相同的结果window.location.replace("myapp://myparam").
Web应用程序的html是:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>untitled</title>
<meta name="generator" content="TextMate http://macromates.com/">
<meta name="author" content="Carl Veazey">
<!-- Date: 2012-04-19 -->
<meta name="viewport" content="width=device-width; initial-scale=1.0; maximum-scale=1.0; user-scalable=0;" />
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta names="apple-mobile-web-app-status-bar-style" content="black-translucent" />
</head>
<body>
<script type="text/javascript" charset="utf-8">
if (window.navigator.userAgent.indexOf('iPhone') != -1) {
if (window.navigator.standalone == true) {
window.location …Run Code Online (Sandbox Code Playgroud) 首先,我的问题非常类似于此,这个和这个.我想要实现的Android文档就在这里.我无法使用这些资源来使用它,所以请不要将其标记为重复,因为它不是.
我有一个网站和一个Android应用程序.用户将能够扫描包含http://mywebsite.com/map/等链接的QR码.当用户尝试打开此链接时,我希望Android向他显示一个选择器对话框,他可以选择使用我的应用程序打开该链接.如果我的应用程序没有安装,它应该进入指定的网站.
我知道当用户导航到该地址时,Chrome会通过打开选择器对话框来实现此目的.例如,尝试下载Stack Exchange应用程序并在Chrome中转到此问题.它会显示:

按照上述答案中的建议后,我在AndroidManifest.xml中添加了以下代码:
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<action android:name="android.intent.action.SEND" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data
android:host="mywebsite.com"
android:path="/map"
android:scheme="http" />
<data
android:host="mywebsite.com"
android:path="/animals"
android:scheme="http" />
<data
android:host="mywebsite.com"
android:path="/articles"
android:scheme="http" />
</intent-filter>
Run Code Online (Sandbox Code Playgroud)
另外,我尝试将android:mimeType ="text/plain"添加到数据中,但它没有帮助.
问题是,当我访问http://mywebsite.com/map或http://mywebsite.com/map/时, Chrome只会打开网页而不显示选择器对话框.
我想提一下:
我试过link1,link2,link3,link4,link5,link6
以下是有关DeepLinking的所有内容
我想要的是自定义uri myapp:// some_data,打开设备中安装的本机应用程序,需要some_data初始化应用程序.
有两种方案可以单击自定义URL.
1)在SMS应用程序内,当用户点击链接时,它应自动打开已安装的,否则打开应用程序托管的googleplay商店
2)从电子邮件正文中.
我已经尝试了以上列出的所有链接,但它们都不适用于我.我对方案部分有重大问题.
这是我的AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
Run Code Online (Sandbox Code Playgroud)
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="18" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="MainActivity"
android:label="@string/app_name"
android:exported="true" >
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.BROWSABLE" />
<category android:name="android.intent.category.DEFAULT" />
<data android:scheme="inderbagga" />
</intent-filter>
</activity>
</application>
Run Code Online (Sandbox Code Playgroud)
这是MainActivity.java
TextView tvText=(TextView)findViewById(R.id.tvid);
if (getIntent().getAction() == Intent.ACTION_VIEW&&getIntent().getScheme().equals("inderbagga")) {
Toast.makeText(getApplicationContext(), ""+getIntent().getScheme(), Toast.LENGTH_SHORT).show();
Uri uri = getIntent().getData();
// do stuff with uri
tvText.setText(uri.toString());
}
else …Run Code Online (Sandbox Code Playgroud) 我知道要从网页内的链接打开android应用程序,我们必须在AndroidManifest.xml中编写以下内容:
<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="my_scheme" android:host="my_host" />
</intent-filter>
Run Code Online (Sandbox Code Playgroud)
问题是我用以下方式编写它:
<intent-filter>
<action android:name="my_action"/>
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="my_scheme" android:host="my_host" />
</intent-filter>
Run Code Online (Sandbox Code Playgroud)
我没有添加"android.intent.action.VIEW",而是添加了我自己的动作.我无法更改它,因为该版本已经发布.
问题是,如果有办法让应用程序从JavaScript或简单的html页面运行,可能是通过定义页面中的特定操作?
谢谢,
拉巴斯.
解决了:
感谢大卫我找到了一个解决方案:
<a href="intent://my_host#Intent;scheme=my_scheme;action=my_action;end">Link to my stuff</a>
Run Code Online (Sandbox Code Playgroud) android ×8
intentfilter ×5
javascript ×2
uri ×2
action ×1
browser ×1
deep-linking ×1
flutter ×1
html ×1
http ×1
ios ×1
launch ×1
url ×1