Cordova removing my changes in main activity class after building cordova project

泄露秘密 提交于 2020-01-16 01:09:07

问题


I am adding some extra stuff in my cordova project's Main activity class (overriding some functions like onResume) but cordova remove them after every cordovaBuild. What should I do to prevent this behaviuor?


回答1:


Sorry I have no time right now to elaborate.

If you don't know how to do plugins, the easyest is to go with hooks.

Basically hooks are scripts you can add between each step of cordova cli.

so you would add

  • a script in projecthome/.cordova/hooks/before_prepare to save your java file
  • a script in projecthome/.cordova/hooks/before_compile to put your java class back in place

the script are javascript nodejs scripts, I think just copy a file should not be too complicated to learn.

Here are some links about cordova cli hooks :

  • http://www.mooreds.com/wordpress/archives/1197
  • http://devgirl.org/2013/11/12/three-hooks-your-cordovaphonegap-project-needs/


来源:https://stackoverflow.com/questions/22080013/cordova-removing-my-changes-in-main-activity-class-after-building-cordova-projec

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!