var Runnable = Java.use("java.lang.Runnable"); | header |
var saveImg = Java.registerClass({ //注册一个类
name: "com.example.runnable", //包名
implements: [Runnable], //实现Runnable
fields: {
bm: "android.graphics.Bitmap",
},
methods: {
$init: [{
returnType: "void",
argumentTypes: ["android.graphics.Bitmap"],
implementation: function (bitmap) {
this.bm.value = bitmap;
}
}],
run: function () {
var path = "/sdcard/Download/tmp/" + guid() + ".jpg"
console.log("path=> ", path)
var file = Java.use("java.io.File").$new(path)
var fos = Java.use("java.io.FileOutputStream").$new(file);
this.bm.value.compress(Java.use("android.graphics.Bitmap$CompressFormat").JPEG.value, 100, fos)
console.log("success!")
fos.flush();
fos.close();
}
}
});