1. Websocket的Okhttp 配套太老哨免。
??Weex示例里面的低版本的okhttp onMessage方法回調(diào)監(jiān)聽(tīng)會(huì)丟失數(shù)據(jù)枕稀。在換用Ok3成功解決這個(gè)問(wèn)題弟翘。具體代碼塊:
OkHttpClient.Builder httpBuilder = new okhttp3.OkHttpClient.Builder();
OkHttpClient okHttpClient = httpBuilder.connectTimeout(10, TimeUnit.SECONDS)
.readTimeout(10, TimeUnit.SECONDS).build();
okhttp3.Request request = new Request.Builder().url(url).build();
okHttpClient.newWebSocket();
2.Weex 獲取當(dāng)前頁(yè)面的實(shí)例
??在weex示例代碼的WeexPageActivity里面會(huì)靜態(tài)引用當(dāng)前acitivty對(duì)象命斧,這樣的操作很不對(duì)近忙,如果你代碼依照示例代碼來(lái)竭业,會(huì)造成內(nèi)存泄露智润。比較正確的方式是,采用Activity棧的模式存儲(chǔ)起來(lái)未辆。最不濟(jì)也要在界面銷毀的時(shí)候置空窟绷。
??另外一個(gè)點(diǎn)是weex 的activity在回退的時(shí)候不會(huì)重新賦值,假設(shè)A跳到B,A的acitcity變成了B的activity咐柜,回退后兼蜈,WxpageActivity持有的還是ActivityB對(duì)象。這時(shí)候會(huì)你調(diào)用改對(duì)象很大可能造成應(yīng)用崩潰拙友。
??所以为狸,你可以選擇在調(diào)用onResume方法時(shí)使用以下代碼塊
@Override
protected void onResume() {
super.onResume();
if (mInstance != null) {
Log.e("update", "wxPageActivityInstance 重新賦值");
wxPageActivityInstance = this;
mInstance.onActivityResume();
}
}
3.阿里云推送跳轉(zhuǎn)問(wèn)題(跳到指定的本地Weex頁(yè)面)
首先在指定的方法里面執(zhí)行startActivity跳轉(zhuǎn)到WxpageActivity.
然后在WxpageActivity里面通過(guò)getIntent方法判斷頁(yè)面跳轉(zhuǎn)的來(lái)源。執(zhí)行以下代碼塊
mConfigMap.put("bundleUrl", "xxx"+msgId);
mInstance.render(TAG, WXFileUtils.loadAsset("pages/msgDetail.js", WXPageActivity.this),
mConfigMap,msgId+"" ,
ScreenUtil.getDisplayWidth(WXPageActivity.this), ScreenUtil
.getDisplayHeight(WXPageActivity.this),
WXRenderStrategy.APPEND_ASYNC);
未完待續(xù)遗契,估計(jì)還有坑辐棒。