worr
worr

Reputation: 809

Launch camera activity with alternate permissions

I'd like to launch the camera activity and have it dump subsequent pictures into my private app storage. Since the camera doesn't have write permission to that directory, it can't save any of its pictures there.

I could make my private app storage world writable, but that defeats the purpose of having it be private.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    Intent cameraIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
    cameraIntent.putExtra(MediaStore.EXTRA_OUTPUT,
            Uri.fromFile(new File(this.getBaseContext().getDir(PHOTOHUNT_DIRNAME, MODE_PRIVATE), "filename")));
    startActivityForResult(cameraIntent, CAPTURE_IMAGE_ACTIVITY_REQUEST_CODE);
}

Something like the above would be idea. Obviously this doesn't work for the reasons stated above.

Upvotes: 1

Views: 145

Answers (1)

CommonsWare
CommonsWare

Reputation: 1006799

I'd like to launch the camera activity and have it dump subsequent pictures into my private app storage.

That is not possible, sorry. Either use the Camera object yourself, or have the activity write the photos to world-writable storage and then move them to your app-local file store yourself.

Upvotes: 1

Related Questions