Android意图、onActivityResult,并将这些结果保存到Parse.com

Android意图、onActivityResult,并将这些结果保存到Parse.com,android,android-intent,android-camera,parse-platform,Android,Android Intent,Android Camera,Parse Platform,我正在尝试使用MediaStore.ACTION_IMAGE_capture Intential拍摄照片,但在让它实现我想要的功能时遇到了一些问题。我已经启动了相机,我可以用它拍照,但是我有一些不同的动作需要执行,这取决于在什么阶段按下什么按钮 基本上: 如果打开相机并按下后退按钮,则退出活动类 拍照后,如果按“放弃”,则返回“照相机意图” 拍照后,如果按Save,则返回到camera intent 在我的活动中,我有一个从onCreate方法调用的方法: private void disp

我正在尝试使用MediaStore.ACTION_IMAGE_capture Intential拍摄照片,但在让它实现我想要的功能时遇到了一些问题。我已经启动了相机,我可以用它拍照,但是我有一些不同的动作需要执行,这取决于在什么阶段按下什么按钮

基本上:

  • 如果打开相机并按下后退按钮,则退出活动类
  • 拍照后,如果按“放弃”,则返回“照相机意图”
  • 拍照后,如果按Save,则返回到camera intent
在我的活动中,我有一个从onCreate方法调用的方法:

private void dispatchTakePictureIntent() {
    Intent i = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
    if (i.resolveActivity(getPackageManager()) != null) {
        startActivityForResult(i, REQUEST_IMAGE_CAPTURE);
    }
}
这似乎很有效。我遇到的问题与我的onActivityResult方法有关

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (requestCode == REQUEST_IMAGE_CAPTURE && resultCode == RESULT_OK) {
        Bundle extras = data.getExtras();
        Bitmap image = (Bitmap )extras.get("data");
        // Here is where I'm stuck. The docs I've found 
        // are saying this is only a thumbnail.
        // I need to get it as a byte array, I think.
        dispatchTakePictureIntent(); // I'm getting camera intents stacking
                                     // on top of each other from this
                                     // I think there's a way to close them 
                                     // after launching a new one
    }
    // Here is where I think I need to put the if statement 
    // to handle the Discard resultCode
}
// I'm trying to save the photos and upload them to parse
private void savePhoto(byte[] data) {
    parseFile = new ParseFile(ParseUser.getCurrentUser().getUsername()
        + System.currentTimeMillis() + .jpg", data);
    // Some other parse methods
    parseFile.saveInBackground(new SaveCallBack() {
        // More parse stuff
    });
}
这是我第一次使用相机,所以我一直在阅读android文档,但我找不到有什么帮助。

可以帮助您开始。。。