android.util.Log is a very useful class to help developer debug their application. But when in production release. Any verbose log (Log.v) should be removed properly to prevent annoying user or leak some information.
You can simply commented those Log.v out or Using a ProGuard to remove any verbose log statements directly from the bytecode of your compiled JAR executable. This method is described in Christopher’s answer in the StackOverflow post
The easiest way is to run your compiled JAR through ProGuard before deployment, with a config like:
1 2 3
-assumenosideeffects class android.util.Log { public static int v(...); }
That will – aside from all the other ProGuard optimisations – remove any verbose log statements directly from the bytecode.
###Promise###
在javascript中实现异步最简单的方式是Callback。遗憾的是,这种编程方式牺牲了控制流,同时你也不能throw new Error()并在外部捕获异常。
Promise的出现解决了这两个需求,又保持了javascript异步的优势,不同于Fiber这种多线程的实现方式,Promise只是一种编程方式的变化。而无须在底层改变。
var promise = readFile(); promise .then(function(data){ // we don't need to catch error. in other words. we can throw error in this callback. var obj = JSON.parse(data); obj.prop = 'something new'; // return a promise. so we can chain the then() method. return writeFile(JSON.stringify(obj)); }) .then(function(){ console.log('success'); }, function(err){ // all error will fall down here. console.log(err); });