mirror of
https://github.com/apache/cordova-android.git
synced 2025-02-07 23:03:11 +08:00
Better memory management when taking pictures.
This commit is contained in:
parent
73f278963b
commit
1eae6786c4
@ -201,6 +201,9 @@ public class CameraLauncher extends Plugin {
|
|||||||
// Send Uri back to JavaScript for viewing image
|
// Send Uri back to JavaScript for viewing image
|
||||||
this.success(new PluginResult(PluginResult.Status.OK, uri.toString()), this.callbackId);
|
this.success(new PluginResult(PluginResult.Status.OK, uri.toString()), this.callbackId);
|
||||||
}
|
}
|
||||||
|
bitmap.recycle();
|
||||||
|
bitmap = null;
|
||||||
|
System.gc();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
this.failPicture("Error capturing image.");
|
this.failPicture("Error capturing image.");
|
||||||
@ -228,6 +231,9 @@ public class CameraLauncher extends Plugin {
|
|||||||
try {
|
try {
|
||||||
Bitmap bitmap = android.graphics.BitmapFactory.decodeStream(resolver.openInputStream(uri));
|
Bitmap bitmap = android.graphics.BitmapFactory.decodeStream(resolver.openInputStream(uri));
|
||||||
this.processPicture(bitmap);
|
this.processPicture(bitmap);
|
||||||
|
bitmap.recycle();
|
||||||
|
bitmap = null;
|
||||||
|
System.gc();
|
||||||
} catch (FileNotFoundException e) {
|
} catch (FileNotFoundException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
this.failPicture("Error retrieving image.");
|
this.failPicture("Error retrieving image.");
|
||||||
@ -261,11 +267,15 @@ public class CameraLauncher extends Plugin {
|
|||||||
byte[] output = Base64.encodeBase64(code);
|
byte[] output = Base64.encodeBase64(code);
|
||||||
String js_out = new String(output);
|
String js_out = new String(output);
|
||||||
this.success(new PluginResult(PluginResult.Status.OK, js_out), this.callbackId);
|
this.success(new PluginResult(PluginResult.Status.OK, js_out), this.callbackId);
|
||||||
|
js_out = null;
|
||||||
|
output = null;
|
||||||
|
code = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch(Exception e) {
|
catch(Exception e) {
|
||||||
this.failPicture("Error compressing image.");
|
this.failPicture("Error compressing image.");
|
||||||
}
|
}
|
||||||
|
jpeg_data = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user