andriod从分享的网页中唤起app,并传值到app中进行使用
项目背景
我是个搞前端开发的,这个项目用到了web前端和移动客户端的知识,说起来比较复杂,功能大概是在app里面分享链接出去,在此链接中带好需要的参数,别人点击进链接获得这个参数后,唤起手机里安装的这个app,进入app之后拿到这个参数进行使用.
emmmmm…主要是获得参数和传参,就酱.
对了,还是老实交代一下项目环境.项目的是用cocos2d-x引擎,客户端语言是lua,其他需要用的语言就是html+css+js
下面是步骤:
分为两大步:
一:网页唤起app
-
在AndroidManifest.xml的activity 主入口中加入代码
<intent-filter> <action android:name="android.intent.action.VIEW"/> <category android:name="android.intent.category.DEFAULT"/> <!--网页拉取app--> <category android:name="android.intent.category.BROWSABLE" /> <data android:scheme="userapp" android:host="user.app" android:pathPrefix="/openwith"/> </intent-filter>
此处的scheme和host是调用app的关键
-
写index.html页面,这个页面就是分享出去的链接页面,需要带参数的,页面的复杂程