Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/windows/17.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 在安卓系统中拍摄图像后,如何返回到特定的活动_Android_Android Activity_Camera - Fatal编程技术网

Android 在安卓系统中拍摄图像后,如何返回到特定的活动

Android 在安卓系统中拍摄图像后,如何返回到特定的活动,android,android-activity,camera,Android,Android Activity,Camera,在我的应用程序中,我有两个活动,即A和B。通过单击按钮,我将从活动A移动到活动B。在活动B中,我有一个按钮,当用户点击时,它会根据用户的意愿打开库或相机 在这里,用户选择一个图像或捕获一个图像,图像被上传到服务器。此活动过量后,我想自动显示活动A 如果用户单击默认的后退按钮,我已经编写了代码来移动到活动A,但有时在上传过程后它会自动关闭,在这种情况下,我只想显示活动A,而不想显示活动B。调用finish()完成活动B后,它将可靠地关闭并返回到活动A。使用此功能拍照并将其存储在SD卡中: publ

在我的应用程序中,我有两个活动,即A和B。通过单击按钮,我将从活动A移动到活动B。在活动B中,我有一个按钮,当用户点击时,它会根据用户的意愿打开库或相机

在这里,用户选择一个图像或捕获一个图像,图像被上传到服务器。此活动过量后,我想自动显示活动A


如果用户单击默认的后退按钮,我已经编写了代码来移动到活动A,但有时在上传过程后它会自动关闭,在这种情况下,我只想显示活动A,而不想显示活动B。

调用
finish()完成活动B后,它将可靠地关闭并返回到活动A。

使用此功能拍照并将其存储在SD卡中:

public void takePhoto() {

    Intent intent = new Intent("android.media.action.IMAGE_CAPTURE");
    File folder = new File(Environment.getExternalStorageDirectory() + "/Photo");
    boolean success = false;
    if(!folder.exists()){
        success = folder.mkdir();
    }         
    final Calendar c = Calendar.getInstance();
    String path=String.format("/sdcard/Photo/%s.png","Photos");
    photo = new File(path); 
    intent.putExtra(MediaStore.EXTRA_OUTPUT,Uri.fromFile(photo));
    imageUri = Uri.fromFile(photo);
    startActivityForResult(intent, TAKE_PICTURE);
}
使用onActivityResult方法:

@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    switch (requestCode) {
    case TAKE_PICTURE:
        if (resultCode == Activity.RESULT_OK) {
           // Use your server Post Coding :

           // Get the Rsponse as String and compare here

           if(response.equalsignoreCase("POST SUCCESS")){
            startActivity(new Activity (CurrentActivity.this,Activity2.class))
        }
        super.onActivityResult(requestCode, resultCode, data);
        }
    }

从相机捕获图像后,其将进入onActivityResult()方法检查响应并相应重定向页面。

在发布到服务器后,您是否收到任何响应,如“发布成功”等…您使用的是“活动结果”方法?