android+授权成功返回resultcode为-1,android – Camera始终将resultCode返回为0
我正在尝试使用我的Android应用程序中的相机开发.问题是相机总是返回结果代码0,无论我是按完还是取消.我使用的代码片段如下:protected void startCameraActivity(){Log.i("MakeMachine", "startCameraActivity()" );File file = new File( _path );Uri outputFileUri = Ur
我正在尝试使用我的Android应用程序中的相机开发.
问题是相机总是返回结果代码0,无论我是按完还是取消.
我使用的代码片段如下:
protected void startCameraActivity()
{
Log.i("MakeMachine", "startCameraActivity()" );
File file = new File( _path );
Uri outputFileUri = Uri.fromFile( file );
Intent intent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
intent.putExtra( MediaStore.EXTRA_OUTPUT, outputFileUri );
startActivityForResult(intent, 0);
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data)
{
Log.i( "MakeMachine", "resultCode: " + resultCode );
switch( resultCode )
{
case 0:
Log.i( "MakeMachine", "User cancelled" );
break;
case -1:
Log.i( "MakeMachine", "User done" );
onPhotoTaken();
break;
}
}
logcat显示:
05-31 14:58:15.367: E/asset(29114): MAS: getAppPckgAndVerCode package: makemachine.android.examples === version 1
05-31 14:58:15.398: D/dalvikvm(29114): Trying to load lib lib_glossary.so 0x0
05-31 14:58:15.414: D/dalvikvm(29114): Added shared lib lib_glossary.so 0x0
05-31 14:58:26.125: I/MakeMachine(29114): ButtonClickHandler.onClick()
05-31 14:58:26.125: I/MakeMachine(29114): startCameraActivity()
05-31 14:58:26.507: W/IInputConnectionWrapper(29114): showStatusIcon on inactive InputConnection
05-31 14:58:36.375: I/MakeMachine(29114): User cancelled
05-31 14:58:36.375: I/MakeMachine(29114): resultCode: 0
05-31 14:58:50.945: I/MakeMachine(29114): ButtonClickHandler.onClick()
05-31 14:58:50.945: I/MakeMachine(29114): startCameraActivity()
05-31 14:58:51.429: W/IInputConnectionWrapper(29114): showStatusIcon on inactive InputConnection
05-31 14:59:01.554: I/MakeMachine(29114): User cancelled
05-31 14:59:01.554: I/MakeMachine(29114): resultCode: 0
更多推荐
所有评论(0)