Android 通过浏览器打开自己的APP
来源:互联网 发布:sql查询所有表 编辑:程序博客网 时间:2024/06/12 00:55
转自:http://blog.csdn.net/qduningning/article/details/37602101
通过用手机的浏览器(内置,第三方都可)访问一个网页,实现点击一个链接启动自己的应用,并传递数据。
首先在Mainifest文件里面对要启动的Activity添加一个过滤器。
<span style="white-space:pre"></span><activity android:name="com.example.helloworld.MainActivity" 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><action android:name="android.intent.action.VIEW"/> <category android:name="android.intent.category.DEFAULT"/> <category android:name="android.intent.category.BROWSABLE"/><data android:scheme="znn"/> </intent-filter> </activity>
在MainActivity接收数据:
public class MainActivity extends Activity implements View.OnClickListener{@Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.activity_main);Intent intent = getIntent();String scheme = intent.getScheme();Uri uri = intent.getData();System.out.println("scheme:"+scheme);if (uri != null) {String host = uri.getHost();String dataString = intent.getDataString();String id = uri.getQueryParameter("d");String path = uri.getPath();String path1 = uri.getEncodedPath();String queryString = uri.getQuery();System.out.println("host:"+host);System.out.println("dataString:"+dataString);System.out.println("id:"+id);System.out.println("path:"+path);System.out.println("path1:"+path1);System.out.println("queryString:"+queryString);}}}
写一个最简单的网页(超链接):
<a href="znn://aa.bb:80/test?p=12&d=1">test</a>
测试地址:www.erdian.net/m.html
测试结果:
scheme:znn
host:aa.bb
dataString:znn://aa.bb:80/test?p=12&id=1
id:1
path:/test
path1:/test
queryString:p=12&d=1
http://www.erdian.net/?p=238
0 0
- Android 通过浏览器打开自己的APP
- android 通过链接打开自己的app
- 仿某助手,通过浏览器直接打开Android 自己的App 应用程序(支持几乎所有浏览器、app)
- Android 通过浏览器打开App
- android 通过浏览器url打开app的设置方法
- Android 通过网页打开自己的APP(scheme)
- Android 通过网页打开自己的APP(scheme)
- Android 通过网页打开自己的APP(scheme)
- Android 通过网页打开自己的APP(scheme)
- Android 通过网页打开自己的APP(scheme)
- Android 通过网页打开自己的APP(scheme)
- Android 通过网页打开自己的APP(scheme)
- 通过浏览器直接打开Android App 应用程序
- 浏览器打开自己App
- 浏览器打开android app
- Android浏览器打开app
- Android通过浏览器打开app页面并且传递值
- 通过浏览器直接打开iOS/Android App 应用程序
- JVM目录
- python学习笔记
- PAT 1006. Sign In and Sign Out (25)
- 构建高可扩Web架构和分布式系统实战
- 一道小小数学题,趣味逻辑的小鸡汤
- Android 通过浏览器打开自己的APP
- mysql 5.6 private_key.pem public_key.pem file not found
- JSP和Servlet的中文乱码处理
- 仿微信中加载网页时带线行进度条的WebView的实现
- Spring中的beanFactory和ApplicationContext的有什么区别和关联
- android悬浮窗口的实现
- 电力大数据
- android studio启动问题
- 算法学习 - 图的拓扑排序