我是Android开发的新手。我正在开发一个应用程序,将身份证中的图像与脸部图像进行比较。从UploadActivity
,用户将捕获身份证,点击“确定”后用户将被提示从LivenessActivity
前置摄像头以捕获用户的脸部。在进行了眨眼动作后,将成功捕捉脸部并自动提示UploadActivity
。在UploadActivity
中,用户将点击“VIEWFACE”按钮,将出现脸部图像。但不幸的是,在捕捉脸部图像时,LivenessActivity
一直出现要求用户再次捕捉。但如果用户点击后退按钮,则会提示{{1如何避免UploadActivity
在捕获面后继续出现?
这是我的LivenessActivity
和Upload Activity
供您参考:
UploadActivity:
LivenessActivity
LivenessActivity:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_upload);
txtPercentage = (TextView) findViewById(R.id.txtPercentage);
progressBar = (ProgressBar) findViewById(R.id.progressBar);
imgPreview = (ImageView) findViewById(R.id.imgPreview);
imgFace = (ImageView) findViewById(R.id.imgFace);
btnCapturePicture = (Button) findViewById(R.id.btnCapturePicture);
btnCapturePicture.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
captureImage();
}
});
Intent i = getIntent();
// boolean flag to identify the media type, image or video
final boolean isImage = i.getBooleanExtra("isImage",true);
previewMedia(isImage);
if (fileUri != null)
//call LivenessActivity
startActivity(new Intent(UploadActivity.this,
LivenessActivity.class));
btnviewface = (Button) findViewById(R.id.btnviewface);
btnviewface.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Bundle extras = getIntent().getExtras();
byte[] face = extras.getByteArray("image_best");
//save byte[] in the sd card, make a folder
try {
Config.IMAGE_FACE = "/storage/emulated/0/Pictures/Android
File Upload/IMG_face.jpg";
FileOutputStream stream = new FileOutputStream(
Config.IMAGE_FACE);
stream.write(face);
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
Bitmap bmp = BitmapFactory.decodeByteArray(face, 0,
face.length);
imgFace.setImageBitmap(bmp);
previewMedia(isImage);
new UploadFileToServer(Config.IMAGE_DOC,
Config.IMAGE_FACE).execute();
}
} );
答案 0 :(得分:0)
删除 public void onActivityResult(int requestCode, int resultCode, Intent resultData)
{
if (requestCode == READ_REQUEST_CODE && resultCode == Activity.RESULT_OK){
uri = resultData.getData();
//do some more stuff
}
中的startActivity,而不是此调用LivenessActivity
或finish()
LivenessActivity.this.finish()