【发布时间】:2016-02-01 17:09:12
【问题描述】:
我想在我的应用中启动相机意图来拍照并将其保存到内部存储中。我正在使用谷歌开发者页面Capturing images or video 的代码。 在 processPictureWhenReady 方法中,我实现了以下代码来保存图片:
private void processPictureWhenReady(final String picturePath) {
Log.v("path processPictureWhenReady ", " " + picturePath);
final File pictureFile = new File(picturePath);
if (pictureFile.exists()) {
// The picture is ready; process it.
try {
Bitmap imageBitmap = BitmapFactory.decodeFile(picturePath);
int w = imageBitmap.getWidth();
int h = imageBitmap.getHeight();
Bitmap bm2 = Bitmap.createScaledBitmap(imageBitmap, w / 2,
h / 2, true);
imageBitmap = bm2.copy(bm2.getConfig(), true);
MediaStore.Images.Media.insertImage(getContentResolver(),
imageBitmap, "test", "Test");
} catch (Exception e) {
Log.e("Exc", e.getMessage());
}
}
相机意图正在启动,然后我可以“点击接受”来拍照。但随后什么也没有发生。我的 onActivityResult 方法中有一条日志消息,并注意到该方法没有被调用。
【问题讨论】:
标签: android google-glass android-camera-intent