get Camera Activity via Intent - Android Intent

Android examples for Intent:Camera Intent

Description

get Camera Activity via Intent

Demo Code


//package com.java2s;
import java.io.File;
import android.content.Intent;
import android.net.Uri;
import android.provider.MediaStore;
import android.text.TextUtils;

public class Main {
    public static Intent getCameraActivity(String outputPath) {

        Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
        if (!TextUtils.isEmpty(outputPath)) {
            Uri uri = Uri.fromFile(new File(outputPath));
            intent.putExtra(MediaStore.EXTRA_OUTPUT, uri);
        } else {/*  ww  w . j  a  v a 2s . co m*/
            intent.addCategory(Intent.CATEGORY_DEFAULT);
            intent.putExtra("return-data", true);
        }
        return intent;
    }
}

Related Tutorials