我正在致力于一个基于android摄像头的应用程序的使用意图。在拍摄一张照片后,我可以看到这张照片和两个按钮出现-“保存”和“取消”。我想要做的是不等待用户选择这两个按钮中的一个,而是开始处理这张照片,然后根据处理的结果执行进一步的操作。
到目前为止我一直是这样做的:
CAPTURE_IMAGE_ACTIVITY_REQUEST_CODE = 100;
protected void startCameraActivity()
{
Intent intent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE );
// the method below is my method for setting proper path for my image file
fileUri = getOutputMediaFileUri(MEDIA_TYPE_IMAGE); // create a file to save the image
intent.putExtra(MediaStore.EXTRA_OUTPUT, fileUri); // set the image file name
startActivityForResult( intent, CAPTURE_IMAGE_ACTIVITY_REQUEST_CODE );
}当我启动我的应用程序时,会调用此方法。所以我用相机启动我的应用程序。然后我拍张照片。我可以选择“保存”或“取消”。当我选择一个方法时,该方法将被调用:
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == CAPTURE_IMAGE_ACTIVITY_REQUEST_CODE) {
if (resultCode == RESULT_OK) {
// Image captured and saved to fileUri specified in the Intent
onPhotoTaken(); // processing...
} else if (resultCode == RESULT_CANCELED) {
// User cancelled the image capture
} else {
// Image capture failed, advise user
}
}
}在收到适当的resultCode后,我从文件中加载该映像,然后开始处理它。
现在我的问题是:,如果我能在调用onActivityResult方法之前得到这个图像?单击其中一个按钮后会调用它。。
(我想用谷歌谷歌( googles )类似的方式来做这件事--用户抓取一张照片,照片马上就会被处理。)
发布于 2012-04-22 03:56:03
您需要实现您自己的拍照活动,类似于这 (包括页面末尾的源代码)。
与使用简单的Intent相比,设置它需要一段时间,但在使用简单的之前,您就可以直接访问所有的相机功能,包括相机图像。
https://stackoverflow.com/questions/10261821
复制相似问题