关于weex页面在android端跳转的问题
PHP中文网
PHP中文网 2017-04-18 09:20:00
0
2
600

在weex页面中通过 navigator.push的方式跳转页面,而在android端是通过startActivity方法隐式跳转页面;所有展示weex页面的activity的intent-filter中都得有如下配置

            <action android:name="com.taobao.android.intent.action.WEEX" />
            <category android:name="android.intent.category.DEFAULT" />
            <category android:name="com.taobao.android.intent.category.WEEX" />
            <action android:name="android.intent.action.VIEW" />

而真正区分是目标activity的是data标签
<data android:scheme="http" android:host="192.168.2.31" android:path="/dist/modules/mymessage.js"/>
那么问题来了是不是我有多少个navigator.push,android端就得有多少个activity?怎样来实现activity复用?
比如 push 的uri地址分别为
http ://192.168.2.31:8080/dist/modules/1
http ://192.168.2.31:8080/dist/modules/2
安照前面的思路 android就得注册两个activity,还有这个最大的缺陷就是你必须提前知道uri参数,如果是weex页面从服务器后台拿的;android就无能为力了。该怎么避免这种情况 ,各位大神请不吝赐教

PHP中文网
PHP中文网

认证高级PHP讲师

reply all(2)
小葫芦

You can refer to the implementation ideas of this project
https://github.com/hanliuxin5...

Ty80

Maybe there is something wrong with your understanding. The loaded page should be the same one every time it is opened. Activity,用默认的navigator跳转,都是加载categorycom.taobao.android.intent.category.WEEXActivity。所以你只注册这一个ActivityThat’s fine. Of course, if there is special processing, you can define your own navigation module and then handle it accordingly.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!