我们正在尝试使用原生相机应用程序让用户拍摄新照片.如果我们省略EXTRA_OUTPUT extra并返回小的Bitmap图像,它就可以正常工作.但是,如果我们putExtra(EXTRA_OUTPUT,...)在启动它之前处于意图状态,那么一切都会有效,直到您尝试点击相机应用程序中的"确定"按钮."确定"按钮无效.相机应用程序保持打开状态,没有任何锁定.我们可以取消它,但文件永远不会被写入.我们究竟要做什么ACTION_IMAGE_CAPTURE才能将拍摄的照片写入文件?
编辑:这是通过MediaStore.ACTION_IMAGE_CAPTURE意图完成的,只是为了清楚
camera android return-value android-intent android-camera-intent
我有一个带开始按钮的简单屏幕.按下"开始"按钮后,我想转到带有SurfaceView的新屏幕以显示相机.
一切正常,但相机需要一段时间才能加载,这给了我一个黑屏.我想加载新的布局.并且在装载后启动相机...
因此,我在后台线程中完成所有相机加载,但仍然,我得到一个黑屏...这是我的布局:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout android:id="@+id/RelativeLayout1"
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/blue_bg">
<SurfaceView
android:id="@+id/surface_camera"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_marginLeft="25dp"
android:layout_marginRight="25dp"
android:layout_below="@id/scan_header"
android:layout_above="@id/scan_footer">
</SurfaceView>
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)
这是我的Activity中的方法,它加载新视图:
private void setContent()
{
setContentView(R.layout.scan)
Thread t = new Thread()
{
public void run()
{
final SurfaceView mSurfaceView = (SurfaceView)findViewById(R.id.surface_camera);
final SurfaceHolder mSurfaceHolder = mSurfaceView.getHolder();
try
{
cameraView = new CameraView();
mSurfaceHolder.addCallback(cameraView);
cameraView.setPictureListener(SunpluggedActivity.this);
mSurfaceHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
} catch(Exception e)
{
Log.d(TAG, "Another exception");
e.printStackTrace();
}
}
};
t.start();
}
Run Code Online (Sandbox Code Playgroud)
为什么新的布局没有显示,直到线程完成加载相机?
编辑:我已经尝试Thread内的Thread.sleep(200)睡了一段时间...当我这样做时,新的布局显示出来,但相机永远不会启动......