Project structure
- configs
- dist
- node_modules
- platforms
- android
- plugins
- src
- web
I'am new to android, where should snippet be saved given java code is meant to be paste somewhere inside android dir. where android dir have all the necessary file to launch the app in android.
In Android
public void onBackPressed(){
Map<String,Object> params=new HashMap<>();
params.put("name","returnmsg");
mWXSDKInstance.fireGlobalEventCallback("androidback",params);
}
In weex
globalEvent.addEventListener('androidback', function (e) {
// 这里就可以做返回事件操作了,如返回上一页或退出应用
// that.$router.go(-1)
// weex.requireModule('close').closeApp()
})
Suspected files inside Android dir:
For further reading please refer weex controls Android return key solution
Simply,
onBackPressedis an event, which will reside inAbsWeexActivity.javafile andglobalEvent.addEventListenercan be attach with suitable Weex lifecycle.This is how event from android to weex could be attached and listen to.