Home » Android » Video trimming using "com.android.camera.action.TRIM" (Gallery2 package)

Video trimming using "com.android.camera.action.TRIM" (Gallery2 package)

Posted by: admin May 14, 2020 Leave a comment


I need to implement trimming operation over a Video.I am using this code, its works perfectly on Gallery2 package installed phones. but its does not return onActivityResult(the intent will not return any results if the triiming was successful).


Intent trimVideoIntent = new Intent("com.android.camera.action.TRIM");

            // The key for the extra has been discovered from com.android.gallery3d.app.PhotoPage.KEY_MEDIA_ITEM_PATH
            trimVideoIntent.putExtra("media-item-path", FilePath);

            // Check if the device can handle the Intent
            List<ResolveInfo> list = getPackageManager().queryIntentActivities(trimVideoIntent, 0);
            if (null != list && list.size() > 0) {
                startActivityForResult(trimVideoIntent,2); // Fires TrimVideo activity into being active
            }else {
                Toast.makeText(this, "Video trimming not supported", 1).show();

Is there any way to close gallery2 after trimming and return result ?

How to&Answers: