Question

I only want to call the system camera take picture not from the third-party. I can not get the result from the third-party or the method I can get result from the third party.

Below is my code;

Intent intent2 = new Intent();
Intent intent_camera = getPackageManager().getLaunchIntentForPackage("com.android.camera");
if (intent_camera != null) {
    intent2.setPackage("com.android.camera");
}

intent2.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
Was it helpful?

Solution

Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); 
List<ResolveInfo> list = getPackageManager().queryIntentActivities(intent, PackageManager.MATCH_DEFAULT_ONLY); 
for (ResolveInfo resolveInfo: list) {
    if (resolveInfo.activityInfo.applicationInfo.
// update to account for unlikely camera app update:
flags & (ApplicationInfo.FLAG_SYSTEM | ApplicationInfo.FLAG_UPDATED_SYSTEM_APP))
// worse approach:
// sourceDir.startsWith("/system/app")) {
        intent.setClassName(resolveInfo.activityInfo.applicationInfo.packageName, resolveInfo.activityInfo.name);
        break;
    }
}

startActivityForResult(intent, actionCode);

OTHER TIPS

you have to do some thing like this. Implement onActivityResult to catch the result

    String name = dateToString(new Date(), "yyyy-MM-dd-hh-mm-ss");
        destination = new File(Environment
                .getExternalStorageDirectory(), Filename + ".jpg");

        Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
        intent.putExtra(MediaStore.EXTRA_OUTPUT,
                Uri.fromFile(destination));
        startActivityForResult(intent, PICK_Camera_IMAGE);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top