In weex on the market after this, feedback appears after the application is opened, in the secondary interface jump, will select multiple applications jump, view information xie.infoq.cn/article/f09… After processing, some solutions are found

  • The solution in this article is to create a new Module class, rewrite the Push method, weeX interface through the new method of the new Module to realize the jump, but in this way, it is necessary to modify the JS interface call method, the upgrade cost is high, and the ios terminal also needs to modify.

Finally, it is considered to rewrite the original push method to solve the jump selection application problem through three steps

1. Create a NavigatorModule that inherits from WXNavigatorModule

Public class JlpayWXNavigatorModule extends WXNavigatorModule { Will choose to jump the problem of private final String CATEGORY_WEEX = "com.com pany. Android. Intent. The category. WEEX"; @JSMethod( uiThread = true ) public void push(String param, JSCallback callback) { if (! TextUtils.isEmpty(param)) { if (WXSDKEngine.getActivityNavBarSetter() ! = null && WXSDKEngine.getActivityNavBarSetter().push(param)) { if (callback ! = null) { callback.invoke("WX_SUCCESS"); } return; } if (this.mWXSDKInstance.getContext() instanceof Activity) { Activity activity = (Activity) this.mWXSDKInstance.getContext(); if (WXSDKEngine.getNavigator() ! = null && WXSDKEngine.getNavigator().push(activity, param)) { if (callback ! = null) { callback.invoke("WX_SUCCESS"); } return; } } try { JSONObject jsonObject = JSON.parseObject(param); String url = jsonObject.getString("url"); if (! TextUtils.isEmpty(url)) { Uri rawUri = Uri.parse(url); String scheme = rawUri.getScheme(); Uri.Builder builder = rawUri.buildUpon(); if (TextUtils.isEmpty(scheme)) { builder.scheme("http"); } Intent intent = new Intent("android.intent.action.VIEW", builder.build()); intent.addCategory(CATEGORY_WEEX); intent.putExtra("instanceId", this.mWXSDKInstance.getInstanceId()); this.mWXSDKInstance.getContext().startActivity(intent); if (callback ! = null) { callback.invoke("WX_SUCCESS"); } } } catch (Exception var9) { WXLogUtils.eTag("Navigator", var9); if (callback ! = null) { callback.invoke("WX_FAILED"); } } } else if (callback ! = null) { callback.invoke("WX_FAILED"); }}}Copy the code
  1. Register this Module in WxSDKEngine

WXSDKEngine.registerModule("navigator", JlpayWXNavigatorModule.class);
Copy the code
  1. Update the Category that responds to WeexPageAcitvity in the AndroidManifest file.

    <activity android:name=".weex.WXPageActivity" android:screenOrientation="portrait"> <intent-filter> <action android:name="android.intent.action.VIEW" /> <action android:name="com.alibaba.weex.protocol.openurl" /> <action android:name="com.taobao.android.intent.action.WEEX" /> <category android:name="android.intent.category.DEFAULT" /> <category android:name="com.company.android.intent.category.WEEX" /> <category android:name="android.intent.category.BROWSABLE" /> <data android:scheme="http" /> <data android:scheme="https" /> <data  android:scheme="file" /> <data android:scheme="wxpage" /> </intent-filter> </activity>Copy the code

Operation, smooth solution. Note that CATEGORY_WEEX in 1 and category in 3 match