从网页打开android应用程序
Open android application from a web page
我知道,要从网页内的链接打开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>
问题是我用以下方式写的:
<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>
我没有添加android.intent.action.VIEW
,而是添加了我自己的操作。我无法更改它,因为该版本已经发布。
问题是,
如果有一种方法可以让应用程序从JavaScript或简单html页面,也许可以通过定义页面中的特定操作?
谢谢,
帕斯。
已解决:
多亏了David,我找到了一个解决方案:
<a href="intent://my_host#Intent;scheme=my_scheme;action=my_action;end">Link to my stuff</a>
试试这个:
让你的链接看起来像这样:
<a href="intent:#Intent;action=my_action;end">Link to my stuff</a>
还可以看看从android浏览器启动自定义android应用程序
AndroidMainfest声明:
<activity android:name="...">
<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:host="hostName"
android:path="path"
android:scheme="schemeName" />
</intent-filter>
</activity>
您可以允许调用
<a href = "schemeName://hostName/path">
或在浏览器中添加类似url的参数
<a href = "schemeName://hostName/path?id=1&name=mark">
单向林平君saied,另一种方法是调用js方法,代码如下:
function openAActivity(){
window.location = "schemeName://hostName/path"
}
此方法将发送一个Android意图来启动指定的活动。
第一种方式:
<html><head></head><body>
<iframe src="YourApp://profile/blabla" width="1px" height="1px" scrolling="no" frameborder="0"></iframe>
<script>
setTimeout(function() {
window.location = "http://YourSite.com/profile/blabla"; }, 4000
);
</script>
</body>
</html>
或者
第二路:https://stackoverflow.com/a/24023048/2165415
相关文章:
- 使用电话间隙在Android应用程序中显示SQL Lite的数据
- 在cordova android应用程序中连接数据库
- 使用javascript将视频从我的android应用程序上传到youtube
- 我需要学习Java才能使用phoneGap创建android应用程序吗
- javascript onclick不适用于android应用程序
- 带有Apache Cordova的Android应用程序
- Phonegap 3.2.0 android应用程序后退按钮剪切仅适用于某些页面
- 如何在android应用程序中下载图像
- 从网页打开android应用程序
- 点击按钮在手机中加载现有的Android应用程序
- Android应用程序在接收intent捆绑包时崩溃
- 读取phonegap android应用程序中的本地文件
- 如何使我的phonegap android应用程序崩溃
- Pebble Watchface向Android应用程序发送消息
- 让Laravel应用程序同时服务于基于浏览器的应用程序,并充当iPhone和Android应用程序的API的最佳实践是什
- 适用于 Android 应用程序的 Java 代码中的实例化异常
- 为什么我在尝试使用 StageWebView 在 AIR Android 应用程序中实现 Google Maps Jav
- 单击从Android应用程序到HTML页面的单选按钮
- 运行代码以在Android应用程序中单击javascript按钮?尝试在页面上抓取回复按钮联系信息 craigslist
- 如何在 AIR Android 应用程序中在 JS 和 AS3 之间进行通信