1

I'm writing a GDK app that listens for the camera to take a photo and upload it to service. It looks like I'm only getting returned the file path for the image rather then the bitmap data. Saving the file to the file system is taking about 5 seconds (down from 10 seconds with the new XE11). But the intent resolves much faster. Can I get access to the bitmap data before it is saved to the file system?

if ((android.os.Build.PRODUCT).equals("google_sdk")) {
    // Emulator
    mImageBitmap = (Bitmap) extras.get("data");
}
else if ((android.os.Build.PRODUCT).equals("glass_1")) {
    // Glass
    String filePath = (String) extras.get("picture_file_path");
    File imageFile = new File(filePath);
    // Pull bitmap from image file
    mImageBitmap = ...;
}
// Do stuff with bitmap
4

1 回答 1

0

由于拍摄照片时在 Glass 上进行了处理,onActivityResult因此调用该文件时可能不会立即可用。

有关更多信息,请参阅GlassCamera类的 Javadoc。推荐的做法是使用aFileObserver来观察图片文件路径的父目录对于文件CLOSE_WRITE上的一个事件,此时你就知道图片已经准备好了。

于 2013-11-23T00:50:20.353 回答