List of usage examples for android.provider MediaStore ACTION_VIDEO_CAPTURE
String ACTION_VIDEO_CAPTURE
To view the source code for android.provider MediaStore ACTION_VIDEO_CAPTURE.
Click Source Link
From source file:com.waz.zclient.pages.main.conversation.ConversationFragment.java
@Override public void onRequestPermissionsResult(int requestCode, int[] grantResults) { if (assetIntentsManager.onRequestPermissionsResult(requestCode, grantResults)) { return;/*w w w . j a v a2s . c o m*/ } switch (requestCode) { case OPEN_EXTENDED_CURSOR_IMAGES: if (PermissionUtils.verifyPermissions(grantResults)) { openExtendedCursor(ExtendedCursorContainer.Type.IMAGES); } break; case CAMERA_PERMISSION_REQUEST_ID: if (PermissionUtils.verifyPermissions(grantResults)) { Intent takeVideoIntent = new Intent(MediaStore.ACTION_VIDEO_CAPTURE); if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.JELLY_BEAN_MR1) { takeVideoIntent.putExtra(MediaStore.EXTRA_VIDEO_QUALITY, 0); } startActivityForResult(takeVideoIntent, REQUEST_VIDEO_CAPTURE); } else { onCameraPermissionsFailed(); } break; case FILE_SHARING_PERMISSION_REQUEST_ID: if (PermissionUtils.verifyPermissions(grantResults)) { for (Uri uri : sharingUris) { getStoreFactory().getConversationStore().sendMessage(AssetFactory.fromContentUri(uri), assetErrorHandler); } sharingUris.clear(); } else { ViewUtils.showAlertDialog(getActivity(), R.string.asset_upload_error__not_found__title, R.string.asset_upload_error__not_found__message, R.string.asset_upload_error__not_found__button, null, true); } break; case AUDIO_PERMISSION_REQUEST_ID: // No actions required if permission is granted // TODO: https://wearezeta.atlassian.net/browse/AN-4027 Show information dialog if permission is not granted break; case AUDIO_FILTER_PERMISSION_REQUEST_ID: if (PermissionUtils.verifyPermissions(grantResults)) { openExtendedCursor(ExtendedCursorContainer.Type.VOICE_FILTER_RECORDING); } else { Toast.makeText(getActivity(), R.string.audio_message_error__missing_audio_permissions, Toast.LENGTH_SHORT).show(); } break; case SAVE_IMAGE_PERMISSION_REQUEST_ID: if (PermissionUtils.verifyPermissions(grantResults)) { saveImageAssetToGallery(); } else { unableToSaveImageNoPermissions(); } break; default: break; } }
From source file:com.waz.zclient.pages.main.conversation.ConversationFragment.java
@Override public void openIntent(Intent intent, AssetIntentsManager.IntentType intentType) { if (MediaStore.ACTION_VIDEO_CAPTURE.equals(intent.getAction()) && extendedCursorContainer.getType() == ExtendedCursorContainer.Type.IMAGES && extendedCursorContainer.isExpanded()) { // Close keyboard camera before requesting external camera for recording video extendedCursorContainer.close(true); }//from w ww . ja va2 s . c o m startActivityForResult(intent, intentType.requestCode); getActivity().overridePendingTransition(R.anim.camera_in, R.anim.camera_out); }
From source file:org.telegram.ui.ChatActivity.java
@Override public boolean onOptionsItemSelected(MenuItem item) { int itemId = item.getItemId(); switch (itemId) { case android.R.id.home: finishFragment();/*from w w w . j a v a2 s .c o m*/ break; case R.id.attach_photo: { try { Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); File image = Utilities.generatePicturePath(); if (image != null) { takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(image)); currentPicturePath = image.getAbsolutePath(); } startActivityForResult(takePictureIntent, 0); } catch (Exception e) { FileLog.e("tmessages", e); } break; } case R.id.attach_gallery: { try { Intent photoPickerIntent = new Intent(Intent.ACTION_PICK); photoPickerIntent.setType("image/*"); startActivityForResult(photoPickerIntent, 1); } catch (Exception e) { FileLog.e("tmessages", e); } break; } case R.id.attach_video: { try { Intent pickIntent = new Intent(); pickIntent.setType("video/*"); pickIntent.setAction(Intent.ACTION_GET_CONTENT); pickIntent.putExtra(MediaStore.EXTRA_SIZE_LIMIT, (long) (1024 * 1024 * 1000)); Intent takeVideoIntent = new Intent(MediaStore.ACTION_VIDEO_CAPTURE); File video = Utilities.generateVideoPath(); if (video != null) { if (android.os.Build.VERSION.SDK_INT > 16) { takeVideoIntent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(video)); } takeVideoIntent.putExtra(MediaStore.EXTRA_SIZE_LIMIT, (long) (1024 * 1024 * 1000)); currentPicturePath = video.getAbsolutePath(); } Intent chooserIntent = Intent.createChooser(pickIntent, ""); chooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS, new Intent[] { takeVideoIntent }); startActivityForResult(chooserIntent, 2); } catch (Exception e) { FileLog.e("tmessages", e); } break; } case R.id.attach_location: { if (!isGoogleMapsInstalled()) { return true; } LocationActivity fragment = new LocationActivity(); ((ApplicationActivity) parentActivity).presentFragment(fragment, "location", false); break; } case R.id.attach_document: { DocumentSelectActivity fragment = new DocumentSelectActivity(); fragment.delegate = this; ((ApplicationActivity) parentActivity).presentFragment(fragment, "document", false); break; } } return true; }
From source file:kr.wdream.ui.ChatActivity.java
private void processSelectedAttach(int which) { if (which == attach_photo || which == attach_gallery || which == attach_document || which == attach_video) { String action;//from w w w. ja v a2 s .c o m if (currentChat != null) { if (currentChat.participants_count > MessagesController.getInstance().groupBigSize) { if (which == attach_photo || which == attach_gallery) { action = "bigchat_upload_photo"; } else { action = "bigchat_upload_document"; } } else { if (which == attach_photo || which == attach_gallery) { action = "chat_upload_photo"; } else { action = "chat_upload_document"; } } } else { if (which == attach_photo || which == attach_gallery) { action = "pm_upload_photo"; } else { action = "pm_upload_document"; } } if (!MessagesController.isFeatureEnabled(action, ChatActivity.this)) { return; } } if (which == attach_photo) { if (Build.VERSION.SDK_INT >= 23 && getParentActivity() .checkSelfPermission(Manifest.permission.CAMERA) != PackageManager.PERMISSION_GRANTED) { getParentActivity().requestPermissions(new String[] { Manifest.permission.CAMERA }, 19); return; } try { Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); File image = AndroidUtilities.generatePicturePath(); if (image != null) { if (Build.VERSION.SDK_INT >= 24) { takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, FileProvider.getUriForFile( getParentActivity(), BuildConfig.APPLICATION_ID + ".provider", image)); takePictureIntent.addFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION); takePictureIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); } else { takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(image)); } currentPicturePath = image.getAbsolutePath(); } startActivityForResult(takePictureIntent, 0); } catch (Exception e) { FileLog.e("tmessages", e); } } else if (which == attach_gallery) { if (Build.VERSION.SDK_INT >= 23 && getParentActivity().checkSelfPermission( Manifest.permission.READ_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) { getParentActivity().requestPermissions(new String[] { Manifest.permission.READ_EXTERNAL_STORAGE }, 4); return; } PhotoAlbumPickerActivity fragment = new PhotoAlbumPickerActivity(false, currentEncryptedChat == null || AndroidUtilities.getPeerLayerVersion(currentEncryptedChat.layer) >= 46, true, ChatActivity.this); fragment.setDelegate(new PhotoAlbumPickerActivity.PhotoAlbumPickerActivityDelegate() { @Override public void didSelectPhotos(ArrayList<String> photos, ArrayList<String> captions, ArrayList<ArrayList<TLRPC.InputDocument>> masks, ArrayList<MediaController.SearchImage> webPhotos) { SendMessagesHelper.prepareSendingPhotos(photos, null, dialog_id, replyingMessageObject, captions, masks); SendMessagesHelper.prepareSendingPhotosSearch(webPhotos, dialog_id, replyingMessageObject); showReplyPanel(false, null, null, null, false, true); DraftQuery.cleanDraft(dialog_id, true); } @Override public void startPhotoSelectActivity() { try { Intent videoPickerIntent = new Intent(); videoPickerIntent.setType("video/*"); videoPickerIntent.setAction(Intent.ACTION_GET_CONTENT); videoPickerIntent.putExtra(MediaStore.EXTRA_SIZE_LIMIT, (long) (1024 * 1024 * 1536)); Intent photoPickerIntent = new Intent(Intent.ACTION_PICK); photoPickerIntent.setType("image/*"); Intent chooserIntent = Intent.createChooser(photoPickerIntent, null); chooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS, new Intent[] { videoPickerIntent }); startActivityForResult(chooserIntent, 1); } catch (Exception e) { FileLog.e("tmessages", e); } } @Override public boolean didSelectVideo(String path) { if (Build.VERSION.SDK_INT >= 16) { return !openVideoEditor(path, true, true); } else { SendMessagesHelper.prepareSendingVideo(path, 0, 0, 0, 0, null, dialog_id, replyingMessageObject, null); showReplyPanel(false, null, null, null, false, true); DraftQuery.cleanDraft(dialog_id, true); return true; } } }); presentFragment(fragment); } else if (which == attach_video) { if (Build.VERSION.SDK_INT >= 23 && getParentActivity() .checkSelfPermission(Manifest.permission.CAMERA) != PackageManager.PERMISSION_GRANTED) { getParentActivity().requestPermissions(new String[] { Manifest.permission.CAMERA }, 20); return; } try { Intent takeVideoIntent = new Intent(MediaStore.ACTION_VIDEO_CAPTURE); File video = AndroidUtilities.generateVideoPath(); if (video != null) { if (Build.VERSION.SDK_INT >= 24) { takeVideoIntent.putExtra(MediaStore.EXTRA_OUTPUT, FileProvider.getUriForFile( getParentActivity(), BuildConfig.APPLICATION_ID + ".provider", video)); takeVideoIntent.addFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION); takeVideoIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); } else if (Build.VERSION.SDK_INT >= 18) { takeVideoIntent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(video)); } takeVideoIntent.putExtra(MediaStore.EXTRA_SIZE_LIMIT, (long) (1024 * 1024 * 1536)); currentPicturePath = video.getAbsolutePath(); } startActivityForResult(takeVideoIntent, 2); } catch (Exception e) { FileLog.e("tmessages", e); } } else if (which == attach_location) { if (!AndroidUtilities.isGoogleMapsInstalled(ChatActivity.this)) { return; } LocationActivity fragment = new LocationActivity(); fragment.setDelegate(new LocationActivity.LocationActivityDelegate() { @Override public void didSelectLocation(TLRPC.MessageMedia location) { SendMessagesHelper.getInstance().sendMessage(location, dialog_id, replyingMessageObject, null, null); moveScrollToLastMessage(); showReplyPanel(false, null, null, null, false, true); DraftQuery.cleanDraft(dialog_id, true); if (paused) { scrollToTopOnResume = true; } } }); presentFragment(fragment); } else if (which == attach_document) { if (Build.VERSION.SDK_INT >= 23 && getParentActivity().checkSelfPermission( Manifest.permission.READ_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) { getParentActivity().requestPermissions(new String[] { Manifest.permission.READ_EXTERNAL_STORAGE }, 4); return; } DocumentSelectActivity fragment = new DocumentSelectActivity(); fragment.setDelegate(new DocumentSelectActivity.DocumentSelectActivityDelegate() { @Override public void didSelectFiles(DocumentSelectActivity activity, ArrayList<String> files) { activity.finishFragment(); SendMessagesHelper.prepareSendingDocuments(files, files, null, null, dialog_id, replyingMessageObject); showReplyPanel(false, null, null, null, false, true); DraftQuery.cleanDraft(dialog_id, true); } @Override public void startDocumentSelectActivity() { try { Intent photoPickerIntent = new Intent(Intent.ACTION_PICK); photoPickerIntent.setType("*/*"); startActivityForResult(photoPickerIntent, 21); } catch (Exception e) { FileLog.e("tmessages", e); } } }); presentFragment(fragment); } else if (which == attach_audio) { if (Build.VERSION.SDK_INT >= 23 && getParentActivity().checkSelfPermission( Manifest.permission.READ_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) { getParentActivity().requestPermissions(new String[] { Manifest.permission.READ_EXTERNAL_STORAGE }, 4); return; } AudioSelectActivity fragment = new AudioSelectActivity(); fragment.setDelegate(new AudioSelectActivity.AudioSelectActivityDelegate() { @Override public void didSelectAudio(ArrayList<MessageObject> audios) { SendMessagesHelper.prepareSendingAudioDocuments(audios, dialog_id, replyingMessageObject); showReplyPanel(false, null, null, null, false, true); DraftQuery.cleanDraft(dialog_id, true); } }); presentFragment(fragment); } else if (which == attach_contact) { if (Build.VERSION.SDK_INT >= 23) { if (getParentActivity().checkSelfPermission( Manifest.permission.READ_CONTACTS) != PackageManager.PERMISSION_GRANTED) { getParentActivity().requestPermissions(new String[] { Manifest.permission.READ_CONTACTS }, 5); return; } } try { Intent intent = new Intent(Intent.ACTION_PICK, ContactsContract.Contacts.CONTENT_URI); intent.setType(ContactsContract.CommonDataKinds.Phone.CONTENT_TYPE); startActivityForResult(intent, 31); } catch (Exception e) { FileLog.e("tmessages", e); } } }
From source file:com.codename1.impl.android.AndroidImplementation.java
@Override public void captureVideo(ActionListener response) { if (getActivity() == null) { throw new RuntimeException("Cannot capture video in background mode"); }/*w w w . j a va 2 s . com*/ if (!checkForPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE, "This is required to take a video")) { return; } if (getRequestedPermissions().contains(Manifest.permission.CAMERA)) { // Normally we don't need to request the CAMERA permission since we use // the ACTION_VIDEO_CAPTURE intent, which handles permissions itself. // BUT: If the camera permission is included in the Manifest file, the // intent will defer to the app's permissions, and on Android 6, // the permission is denied unless we do the runtime check for permission. // See https://github.com/codenameone/CodenameOne/issues/2409#issuecomment-391696058 if (!checkForPermission(Manifest.permission.CAMERA, "This is required to take a video")) { return; } } callback = new EventDispatcher(); callback.addListener(response); Intent intent = new Intent(android.provider.MediaStore.ACTION_VIDEO_CAPTURE); File newFile = getOutputMediaFile(true); Uri videoUri = FileProvider.getUriForFile(getContext(), getContext().getPackageName() + ".provider", newFile); Storage.getInstance().writeObject("videoUri", newFile.getAbsolutePath()); intent.putExtra(android.provider.MediaStore.EXTRA_OUTPUT, videoUri); intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); if (Build.VERSION.SDK_INT < 21) { List<ResolveInfo> resInfoList = getContext().getPackageManager().queryIntentActivities(intent, PackageManager.MATCH_DEFAULT_ONLY); for (ResolveInfo resolveInfo : resInfoList) { String packageName = resolveInfo.activityInfo.packageName; getContext().grantUriPermission(packageName, videoUri, Intent.FLAG_GRANT_WRITE_URI_PERMISSION | Intent.FLAG_GRANT_READ_URI_PERMISSION); } } this.getActivity().startActivityForResult(intent, CAPTURE_VIDEO); }