Android 通过网页打开自己的APP(scheme)
来源:互联网 发布:php输出时间 编辑:程序博客网 时间:2024/06/06 01:34
版权声明:本文为博主原创文章,未经博主允许不得转载。
通过用手机的浏览器(内置,第三方都可)访问一个网页,实现点击一个链接启动自己的应用,并传递数据。
首先在Mainifest文件里面对要启动的Activity添加一个过滤器。
- <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{
- @Override
- protected 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(scheme)
- Android 通过网页打开自己的APP(scheme)
- Android 通过网页打开自己的APP(scheme)
- Android 通过网页打开自己的APP(scheme)
- Android 通过网页打开自己的APP(scheme)
- Android 通过网页打开自己的APP(scheme)
- Android 通过网页打开自己的APP(scheme)
- 在app或者网页打开自己开发的App(Scheme)
- 通过一个打开APP之 Android scheme
- Android中通过scheme实现网页打开App(deep-link)
- Android 通过浏览器打开自己的APP
- android 通过链接打开自己的app
- 通过链接打开APP(scheme)
- 通过scheme打开另一个APP
- Android Feature(scheme实现网页打开App)小知识点等
- 通过超链接打开一些常见app(android:scheme运用)
- 如何通过网页打开Android APP
- Android scheme的使用--解决浏览器打开app的问题
- 指针函数与函数指针的区别
- acm 贪心总结
- 用户唯一性的校验
- SQL Server 2008可视化设置自增主键
- HDOJ 2053-Switch Game
- Android 通过网页打开自己的APP(scheme)
- mac上搭建svn服务器
- (OK) CentOS 7 + android-ndk-r10d-linux-x86_64 + Android (ARM)—ndk-build
- MFC-用系统快照来枚举进程
- Ubuntu下使用Eclipse IDE for C/C++ Developers交叉编译和调试
- hdu【1712】ACboy needs your help
- (OK—C++程序) Eclipse C/C++ — CentOS 7 + android-ndk + eclipse-cpp-mars-R
- Tpcc-MySQL对mysql数据库进行性能测试报告、分析及使用gnuplot生成图表展示
- 编程范式:线程和信号量的例子-Thread and Semaphore Examples