开发者

start edit activity right after picture is taken at ACTION_IMAGE_CAPTURE activity

First, I launch the camera app to capture picture. Once it is done, I put the image path to extra to launch a edit view activity. When I execute this activity, I found it always return to this activity after picture taken and then start the edit activity. How could I avoid to come back to this activity and start the edit activity right after the picture is taken from camera view?

public void onSnapBtnClick(View v ) {
    Intent intent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
    mImagePath = createImagePath();
    intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(new File(mImagePath)));
    startActivityForResult(intent, ACTIVITY_SNAP);
}


@Override
protected void onActivityResult(int requestCode, int resultCode, Intent intent) {
if (requestCode == ACTIVITY_SNAP && resultCode == Activity.RESULT_OK) {
    File fi = null;
    try {
    fi = new File(mImagePath);
    } catch (Exception ex) {
    Log.w(Config.LOGTAG, "mImagePath not exist " + mImagePath);
    }

    if (fi != null && fi.exists()) {

    String randomId = UUID.randomUUID().toString();
    new ImageUploadAsynTask().execute(randomId);
    Intent editIntent = new Intent(this, ShopinionEditTextActivity.class);
    editIntent.putExtra(GeatteDBAdapter.KEY_IMAGE_PATH, mImagePath);
    editIntent.putExtra(Config.EXTRA_IMAGE_RANDOM_ID, randomId);
    startActivity(editIntent);
  开发者_开发问答  } else {
    Log.w(Config.LOGTAG, "file not exist or file is null");
    }

} 
}


I belive this is impossible because you are launching a seperate app activity which you have no control over. Instead, do this:

From your home activity, launch the EditActivity. The EditActivity will have code that immediately in the onCreate launches the camera app using startActivityForResult(); The user should not be able to see the activity if you launch another one in the onCreate method.

In the EditActivity's onActivityResult have it check the return code, and do whatever you need. If the picture was taken successfully, continue using the Edit activity. IF not, finish and go back to the home activity.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜