I'm trying to develop an application which records the video using default application and writes to sd card and then return the sd card path to previous activity. Why it is not working for me?? i'm getting cancelled toast all the time when I click back button in the camera.
public class AndroidVideoActivity extends Activity {
final static int REQUEST_VIDEO_CAPTURED = 1;
Uri uriVideo = null;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Button btnVideoRecorder = (Button) findViewById(R.id.buttonClick);
btnVideoRecorder.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent("android.media.action.VIDEO_CAMERA");
startActivityForResult(intent, REQUEST_VIDEO_CAPTURED);
}
});
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
// TODO Auto-generated method stub
if (resultCode == RESULT_OK) {
if (requestCode == REQUEST_VIDEO_CAPTURED) {
uriVideo = data.getData();
Toast.makeText(AndroidVideoActivity.this, uriVideo.getPath(),
Toast.LENGTH_LONG).show();
}
} else if (resultCode == RESULT_CANCELED) {
uriVideo = null;
Toast.makeText(AndroidVideoActivity.this, "Cancelled!",
Toast.LENGTH_LONG).show();
}
}
}
You shouldn't have to hit the back button - the back button = cancel. You should be able to record the video, and when you stop recording, you should press 'Done' or something similar (I've only done this with camera, not video), and then it will return to your app automatically.