问题
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