0

I tried to capture video using camera intent and gets the video in onActivityResult. Its working fine except for certain situations.

When i capture video for a long time in certain phones, and when i click save button, it returns to the camera itself. And when i press back button from there it returns to my app, but to a new activity.

// Calling camera intent
Intent intent = new Intent(
                     android.provider.MediaStore.ACTION_VIDEO_CAPTURE);
            startActivityForResult(intent, 1);
@Override
protected void onActivityResult(int requestCode, int resultCode,
        Intent videoReturnedIntent) {
    super.onActivityResult(requestCode, resultCode, videoReturnedIntent);

    if (resultCode == RESULT_OK) {

        float size = 0;
        Uri selectedVideo = videoReturnedIntent.getData();

        String[] filePathColumn = { MediaStore.Video.Media.DATA };
        Cursor cursor = getContentResolver().query(selectedVideo,
                filePathColumn, null, null, null);
        if (cursor != null) {
            cursor.moveToFirst();
            int columnIndex = cursor.getColumnIndex(filePathColumn[0]);
            filePath = cursor.getString(columnIndex);
            cursor.close();
                    }
                }
              }
Elezabeth Mathew
  • 161
  • 2
  • 14
  • Make sure your app doesn't get killed while the cam is working.... sometimes camera app consumes a lot of the memory, so android may kill your app – Mr.Me Feb 07 '13 at 10:17
  • Yes the activity calling camera intent gets killed. Could you please suggest a way to handle the issue. – Elezabeth Mathew Feb 07 '13 at 10:47

1 Answers1

0

This happens when your activity gets killed. I would suggest making a Service, as, in that way, Android would only be killing it, in case, the phone memory goes too low . If you can look for some broadcasts to be received (depending on what you are trying to do), you may set up a broadcast receiver and then invoke the service on broadcast receipt, else kill the service as well. That way, even the service won't be running all the time.

Jan
  • 859
  • 7
  • 30