一、只打开APP操作

通过用手机的浏览器(内置,第三方都可)访问一个网页,实现点击一个链接启动自己的应用,并传递数据。

首先在Mainifest文件里面对要启动的Activity添加一个过滤器。

网页需要的内容

 <html>  

    <head>  

        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">  

        <title>打开App</title>  

    </head>  

    <body>  

        <a href="m://baoming/">打开app</a><br/>  

    </body>  

</html> 

主要的就是a标签里边的内容,href连接的地址要在Android  AndroidManifest.xml中配置

AndroidManifest.xml中的内容

第一种:(可以通过地址打开,有一个问题,运行之后可以打开app但是没有启动图标)

 <activity
android:name=".MainActivity"
android:configChanges="orientation|locale"
android:screenOrientation="portrait">
<intent-filter>
<action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> <action android:name="android.intent.action.VIEW" /> <category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" /> <data
android:host="baoming"
android:scheme="m" />
</intent-filter>
</activity>

第二种(可以启动,有启动图标)

 <activity
android:name=".MainActivity"
android:configChanges="orientation|locale"
android:screenOrientation="portrait">
<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" />
<category android:name="android.intent.category.BROWSABLE" /> <data
android:host="baoming"
android:scheme="m" />
</intent-filter>
</activity>

二、打开APP并且获取携带数据

我们可以使用上述的方法,把一些数据传给本地app,那么首先我们更改一下网页,代码修改后:

首先修改网页内容

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
<a href="m://my.com/?arg0=marc&arg1=xie">打开app</a><br/>
</body>
</html>

(1).假如你是通过浏览器打开这个网页的,那么获取数据的方式为:

Uri uri = getIntent().getData();  String test1= uri.getQueryParameter("arg0");  String test2= uri.getQueryParameter("arg1");
  1. Uri uri = getIntent().getData();
  2. if (uri != null) {
  3. String test1 = uri.getQueryParameter("arg0");
  4. String test2 = uri.getQueryParameter("arg1");
  5. tv.setText(test1 + test2);
  6. }

(2)如果使用webview访问该网页,获取数据的操作为:

  1. webView.setWebViewClient(new WebViewClient(){
  2. @Override
  3. public boolean shouldOverrideUrlLoading(WebView view, String url) {
  4. Uri uri=Uri.parse(url);
  5. if(uri.getScheme().equals("m")&&uri.getHost().equals("my.com")){
  6. String arg0=uri.getQueryParameter("arg0");
  7. String arg1=uri.getQueryParameter("arg1");
  8. }else{
  9. view.loadUrl(url);
  10. }
  11. return true;
  12. }
  13. });

上面只是实现了 传参等操作。但是如果需要判断是否安装了该应用。

  1. <html>
  2. <head>
  3. <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  4. <title>Insert title here</title>
  5. </head>
  6. <body>
  7. <script language="javascript">
  8. function openApp(){
  9. window.location.href = 'm://marc.com/?arg0=marc&arg1=xie';  //app内部
  10. setTimeout(function(){
  11. window.location.href='http://www.wln100.com/Aat/App/index.html';//下载app的网页
  12. },500);
  13. }
  14. </script>
  15. <a href="javascript:openApp()">打开app</a><br/>
  16. </body>
  17. </html>

Android网页打开指定App的更多相关文章

  1. Android 网页打开app(或者打开指定页面)并且接收参数

    网页打开app 现实描述场景: 1.短信通知中通知内容,比如信息中一个咨询详情,流程步骤,信息中的地址打开的是一个网页,网页打开就指定app或者app中的指定页面 html代码 <html> ...

  2. Android后台监控指定app的输入内容,抢红包,模拟点击原理

    Android开启辅助功能之后可以用AccessibilityService 去后台监控指定的app的输入内容,也可以监控到app的动作 以及通知栏的动作, 抢红包其实就根据通知栏出现了红包的通知消息 ...

  3. iOS中通过链接地址打开指定APP并传参 by徐文棋

    基于项目需要,有时候需要通过一个链接,或者二维码扫描来直接打开我们所开发的客户端. 当然了.客户端也不仅仅是需要被打开,而且还要跳到相应的页面去,因此这里需要传参. 客户端想用链接打开,必须要在inf ...

  4. Android应用安全开发之浅谈网页打开APP

    一.网页打开APP简介 Android有一个特性,可以通过点击网页内的某个链接打开APP,或者在其他APP中通过点击某个链接打开另外一个APP(AppLink),一些用户量比较大的APP,已经通过发布 ...

  5. Android 通过网页打开自己的APP(scheme)

    Android 通过网页打开自己的APP(scheme) 分类: android2014-07-09 17:35 8565人阅读 评论(2) 收藏 举报 通过用手机的浏览器(内置,第三方都可)访问一个 ...

  6. android -------- 打开本地浏览器或指定浏览器加载,打电话,打开第三方app

    开发中常常有打开本地浏览器加载url或者指定浏览器加载, 还有打开第三方app, 如 打开高德地图 百度地图等 在Android程序中我们可以通过发送隐式Intent来启动系统默认的浏览器. 如果手机 ...

  7. android之打开网页

    首先改写strings.xml文件 代码如下: <resources> <string name="app_name">Intent应用</strin ...

  8. Java程序打开指定地址网页

    1.今天遇到了需要手动输入http地址打开指定网页的需求,试着做一个用程序打开指定网页的功能,搜了一下,还真有一个现成的例子,稍加改造,实现自己的需求: 2.代码不多,两个文件:如下: package ...

  9. 在线制作微信跳转浏览器下载app/打开指定页面源码

    微信自动跳转外部浏览器下载app/打开指定页面源码 源码说明: 适用安卓和苹果系统,支持任何网页链接.并且无论链接是否已经被微信拦截,均可实现微信内自动跳转浏览器打开. 生成的跳转链接具有极佳的防拦截 ...

随机推荐

  1. Dubbo架构设计及原理详解

    Dubbo是Alibaba开源的分布式服务框架,它最大的特点是按照分层的方式来架构,使用这种方式可以使各个层之间解耦合(或者最大限度地松耦合).从服务模型的角度来看,Dubbo采用的是一种非常简单的模 ...

  2. [Swift]LeetCode21. 合并两个有序链表 | Merge Two Sorted Lists

    Merge two sorted linked lists and return it as a new list. The new list should be made by splicing t ...

  3. [Swift]LeetCode131. 分割回文串 | Palindrome Partitioning

    Given a string s, partition s such that every substring of the partition is a palindrome. Return all ...

  4. [Swift]LeetCode563. 二叉树的坡度 | Binary Tree Tilt

    Given a binary tree, return the tilt of the whole tree. The tilt of a tree node is defined as the ab ...

  5. 如何设置使chrome新标签页中打开链接自动跳转到新标签页?

    在新标签打开链接的时候这样点选 Ctrl+左键 或者 鼠标中键 或者 右键链接选择'新标签页中打开链接', 可实现出现新标签页但不自动跳转 但是这个有问题, 即, 新标签只是在背景打开, 操作后并不会 ...

  6. SpringMVC+JWT+Swagger UI+RestFul

    前言: 其实很早就想写这篇文章了,因为我觉得这会对很多新手有指引作用,当初自己也是瞎子过河的摸索着过来的.目前后台开发比较流行的MVC框架中使用Spring MVC还是比较多的,当然还有Spring ...

  7. javascript ES6 新特性之 let

    let的作用是声明变量,和var差不多. let是ES6提出的,在了解let之前,最好先熟悉var的原理. JavaScript有一个机制叫“预解析”,也可以叫“提升(Hoisting)机制”.很多刚 ...

  8. nginx替换响应内容

    因为想要将非业务域名内嵌到微信小程序中,所以用到了nginx的反向代理功能来替换域名实现盗站(缘起:http://www.cnblogs.com/kenwar/p/8288882.html),但是替换 ...

  9. 使用 SetColorFilter 神奇地改变图片的颜色

    关键代码如下: colors.xml文件中定义一个颜色值: <color name="permission_dialog_img_color">#000000</ ...

  10. .net core下使用FastHttpApi构建web聊天室

    一般在dotnet core下构建使用web服务应用都使用asp.net core,但通过FastHttpApi组建也可以方便地构建web服务应用,在FastHttpApi功能的支持下构建多人聊天室是 ...