List of usage examples for android.provider MediaStore ACTION_IMAGE_CAPTURE
String ACTION_IMAGE_CAPTURE
To view the source code for android.provider MediaStore ACTION_IMAGE_CAPTURE.
Click Source Link
From source file:com.afwsamples.testdpc.policy.PolicyManagementFragment.java
@Override public boolean onPreferenceClick(Preference preference) { String key = preference.getKey(); switch (key) { case MANAGE_LOCK_TASK_LIST_KEY: showManageLockTaskListPrompt(R.string.lock_task_title, new ManageLockTaskListCallback() { @Override/*from w w w. jav a 2s . com*/ public void onPositiveButtonClicked(String[] lockTaskArray) { mDevicePolicyManager.setLockTaskPackages(DeviceAdminReceiver.getComponentName(getActivity()), lockTaskArray); } }); return true; case CHECK_LOCK_TASK_PERMITTED_KEY: showCheckLockTaskPermittedPrompt(); return true; case RESET_PASSWORD_KEY: showResetPasswordPrompt(); return false; case LOCK_NOW_KEY: lockNow(); return true; case START_LOCK_TASK: getActivity().startLockTask(); return true; case STOP_LOCK_TASK: try { getActivity().stopLockTask(); } catch (IllegalStateException e) { // no lock task present, ignore } return true; case WIPE_DATA_KEY: showWipeDataPrompt(); return true; case REMOVE_DEVICE_OWNER_KEY: showRemoveDeviceOwnerPrompt(); return true; case REQUEST_BUGREPORT_KEY: requestBugReport(); return true; case REQUEST_PROCESS_LOGS: showFragment(new ProcessLogsFragment()); return true; case SET_ACCESSIBILITY_SERVICES_KEY: // Avoid starting the same task twice. if (mGetAccessibilityServicesTask != null && !mGetAccessibilityServicesTask.isCancelled()) { mGetAccessibilityServicesTask.cancel(true); } mGetAccessibilityServicesTask = new GetAccessibilityServicesTask(); mGetAccessibilityServicesTask.execute(); return true; case SET_INPUT_METHODS_KEY: // Avoid starting the same task twice. if (mGetInputMethodsTask != null && !mGetInputMethodsTask.isCancelled()) { mGetInputMethodsTask.cancel(true); } mGetInputMethodsTask = new GetInputMethodsTask(); mGetInputMethodsTask.execute(); return true; case SET_DISABLE_ACCOUNT_MANAGEMENT_KEY: showSetDisableAccountManagementPrompt(); return true; case GET_DISABLE_ACCOUNT_MANAGEMENT_KEY: showDisableAccountTypeList(); return true; case CREATE_AND_MANAGE_USER_KEY: showCreateAndManageUserPrompt(); return true; case REMOVE_USER_KEY: showRemoveUserPrompt(); return true; case BLOCK_UNINSTALLATION_BY_PKG_KEY: showBlockUninstallationByPackageNamePrompt(); return true; case BLOCK_UNINSTALLATION_LIST_KEY: showBlockUninstallationPrompt(); return true; case ENABLE_SYSTEM_APPS_KEY: showEnableSystemAppsPrompt(); return true; case ENABLE_SYSTEM_APPS_BY_PACKAGE_NAME_KEY: showEnableSystemAppByPackageNamePrompt(); return true; case ENABLE_SYSTEM_APPS_BY_INTENT_KEY: showFragment(new EnableSystemAppsByIntentFragment()); return true; case HIDE_APPS_KEY: showHideAppsPrompt(false); return true; case UNHIDE_APPS_KEY: showHideAppsPrompt(true); return true; case SUSPEND_APPS_KEY: showSuspendAppsPrompt(false); return true; case UNSUSPEND_APPS_KEY: showSuspendAppsPrompt(true); return true; case MANAGE_APP_RESTRICTIONS_KEY: showFragment(new ManageAppRestrictionsFragment()); return true; case APP_RESTRICTIONS_MANAGING_PACKAGE_KEY: showFragment(new AppRestrictionsManagingPackageFragment()); return true; case SET_PERMISSION_POLICY_KEY: showSetPermissionPolicyDialog(); return true; case MANAGE_APP_PERMISSIONS_KEY: showFragment(new ManageAppPermissionsFragment()); return true; case INSTALL_KEY_CERTIFICATE_KEY: showFileViewerForImportingCertificate(INSTALL_KEY_CERTIFICATE_REQUEST_CODE); return true; case REMOVE_KEY_CERTIFICATE_KEY: choosePrivateKeyForRemoval(); return true; case INSTALL_CA_CERTIFICATE_KEY: showFileViewerForImportingCertificate(INSTALL_CA_CERTIFICATE_REQUEST_CODE); return true; case GET_CA_CERTIFICATES_KEY: showCaCertificateList(); return true; case REMOVE_ALL_CERTIFICATES_KEY: mDevicePolicyManager.uninstallAllUserCaCerts(mAdminComponentName); showToast(R.string.all_ca_certificates_removed); return true; case MANAGED_PROFILE_SPECIFIC_POLICIES_KEY: showFragment(new ProfilePolicyManagementFragment(), ProfilePolicyManagementFragment.FRAGMENT_TAG); return true; case LOCK_SCREEN_POLICY_KEY: showFragment(new LockScreenPolicyFragment.Container()); return true; case PASSWORD_CONSTRAINTS_KEY: showFragment(new PasswordConstraintsFragment.Container()); return true; case SYSTEM_UPDATE_POLICY_KEY: showFragment(new SystemUpdatePolicyFragment()); return true; case SET_ALWAYS_ON_VPN_KEY: showFragment(new AlwaysOnVpnFragment()); return true; case NETWORK_STATS_KEY: showFragment(new NetworkUsageStatsFragment()); return true; case DELEGATED_CERT_INSTALLER_KEY: showFragment(new DelegatedCertInstallerFragment()); return true; case DISABLE_STATUS_BAR: setStatusBarDisabled(true); return true; case REENABLE_STATUS_BAR: setStatusBarDisabled(false); return true; case DISABLE_KEYGUARD: setKeyGuardDisabled(true); return true; case REENABLE_KEYGUARD: setKeyGuardDisabled(false); return true; case START_KIOSK_MODE: showManageLockTaskListPrompt(R.string.kiosk_select_title, new ManageLockTaskListCallback() { @Override public void onPositiveButtonClicked(String[] lockTaskArray) { startKioskMode(lockTaskArray); } }); return true; case CAPTURE_IMAGE_KEY: dispatchCaptureIntent(MediaStore.ACTION_IMAGE_CAPTURE, CAPTURE_IMAGE_REQUEST_CODE, mImageUri); return true; case CAPTURE_VIDEO_KEY: dispatchCaptureIntent(MediaStore.ACTION_VIDEO_CAPTURE, CAPTURE_VIDEO_REQUEST_CODE, mVideoUri); return true; case CREATE_WIFI_CONFIGURATION_KEY: showWifiConfigCreationDialog(); return true; case CREATE_EAP_TLS_WIFI_CONFIGURATION_KEY: showEapTlsWifiConfigCreationDialog(); return true; case MODIFY_WIFI_CONFIGURATION_KEY: showFragment(new WifiModificationFragment()); return true; case SHOW_WIFI_MAC_ADDRESS_KEY: showWifiMacAddress(); return true; case SET_USER_RESTRICTIONS_KEY: showFragment(new UserRestrictionsDisplayFragment()); return true; case REBOOT_KEY: reboot(); return true; case SET_SHORT_SUPPORT_MESSAGE_KEY: showFragment(SetSupportMessageFragment.newInstance(SetSupportMessageFragment.TYPE_SHORT)); return true; case SET_LONG_SUPPORT_MESSAGE_KEY: showFragment(SetSupportMessageFragment.newInstance(SetSupportMessageFragment.TYPE_LONG)); return true; case SAFETYNET_ATTEST: DialogFragment safetynetFragment = new SafetyNetFragment(); safetynetFragment.show(getFragmentManager(), SafetyNetFragment.class.getName()); return true; } return false; }
From source file:net.maa123.tatuky.ComposeActivity.java
private void initiateCameraApp() { // We don't need to ask for permission in this case, because the used calls require // android.permission.WRITE_EXTERNAL_STORAGE only on SDKs *older* than Kitkat, which was // way before permission dialogues have been introduced. Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); if (intent.resolveActivity(getPackageManager()) != null) { File photoFile = null;/*from w ww . jav a2 s .c o m*/ try { photoFile = createNewImageFile(); } catch (IOException ex) { displayTransientError(R.string.error_media_upload_opening); } // Continue only if the File was successfully created if (photoFile != null) { photoUploadUri = FileProvider.getUriForFile(this, "net.maa123.tatuky.fileprovider", photoFile); intent.putExtra(MediaStore.EXTRA_OUTPUT, photoUploadUri); startActivityForResult(intent, MEDIA_TAKE_PHOTO_RESULT); } } }
From source file:com.nextgis.ngm_clink_monitoring.fragments.CreateObjectFragment.java
protected void showCameraActivity(GISApplication app) { Intent cameraIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); // Ensure that there's a camera activity to handle the intent if (null != cameraIntent.resolveActivity(getActivity().getPackageManager())) { try {//from w w w .j ava 2s. com String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss", Locale.US).format(new Date()); File tempFile = new File(app.getDataDir(), FoclConstants.TEMP_PHOTO_FILE_PREFIX + timeStamp + ".jpg"); if (!tempFile.exists() && tempFile.createNewFile() || tempFile.exists() && tempFile.delete() && tempFile.createNewFile()) { mTempPhotoPath = tempFile.getAbsolutePath(); Log.d(TAG, "mTempPhotoPath: " + mTempPhotoPath); cameraIntent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(tempFile)); startActivityForResult(cameraIntent, REQUEST_TAKE_PHOTO); } } catch (IOException e) { Toast.makeText(getActivity(), e.getLocalizedMessage(), Toast.LENGTH_LONG).show(); } } }
From source file:com.xpple.jahoqy.ui.activity.ChatActivity.java
/** * ?// ww w . jav a2 s . c o m */ public void selectPicFromCamera() { if (!CommonUtils.isExitsSdcard()) { String st = getResources().getString(R.string.sd_card_does_not_exist); Toast.makeText(getApplicationContext(), st, 0).show(); return; } cameraFile = new File(PathUtil.getInstance().getImagePath(), CustomApplication.getInstance().getUserName() + System.currentTimeMillis() + ".jpg"); cameraFile.getParentFile().mkdirs(); startActivityForResult(new Intent(MediaStore.ACTION_IMAGE_CAPTURE).putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(cameraFile)), REQUEST_CODE_CAMERA); }
From source file:dong.lan.tuyi.activity.MainActivity.java
@Override public void onClick(View v) { switch (v.getId()) { case R.id.toolbar_community: startActivity(new Intent(MainActivity.this, TuyiHomeActivity.class)); overridePendingTransition(R.anim.slide_in_from_left, R.anim.slide_out_to_right); break;//from ww w . j a v a 2 s.c o m case R.id.toolbar_tuyi: startActivity(new Intent(MainActivity.this, TuMapActivity.class)); overridePendingTransition(R.anim.slide_in_from_left, R.anim.slide_out_to_right); break; case R.id.my_Favorite: startActivity(new Intent(MainActivity.this, FavoriteActivity.class)); overridePendingTransition(R.anim.slide_in_from_left, R.anim.slide_out_to_right); break; case R.id.user_des: isGetWeather = true; break; case R.id.offline_tuyi: startActivityForResult(new Intent(MainActivity.this, OfflineTuyiActivity.class), 100); overridePendingTransition(R.anim.slide_in_from_left, R.anim.slide_out_to_right); break; case R.id.user_community: Lock.canPop = false; startActivityForResult(new Intent(MainActivity.this, TuyiCommunityActivity.class), 100); overridePendingTransition(R.anim.slide_in_from_left, R.anim.slide_out_to_right); break; case R.id.user_head: if (Config.tUser == null) { Show("????"); return; } Lock.canPop = false; final Dialog dialog = new AlertDialog.Builder(MainActivity.this).create(); dialog.setCancelable(true); dialog.show(); dialog.getWindow().setContentView(R.layout.dialog_set_head_img); TextView msg = (TextView) dialog.findViewById(R.id.dialog_msg); msg.setText("?"); TextView dialog_left = (TextView) dialog.findViewById(R.id.dialog_left); TextView dialog_right = (TextView) dialog.findViewById(R.id.dialog_right); dialog_left.setText(""); dialog_right.setText(""); dialog_left.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { dialog.dismiss(); File dir = new File(Constant.PICTURE_PATH); if (!dir.exists()) { dir.mkdirs(); } // File file = new File(dir, username + "_head_" + new SimpleDateFormat(TimeUtil.FORMAT_NORMAL).format(new Date())); filePath = file.getAbsolutePath();// ?? Uri imageUri = Uri.fromFile(file); Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); intent.putExtra(MediaStore.EXTRA_OUTPUT, imageUri); startActivityForResult(intent, Constant.REQUESTCODE_UPLOADAVATAR_CAMERA); } }); dialog_right.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { dialog.dismiss(); Intent intent = new Intent(Intent.ACTION_PICK, null); intent.setDataAndType(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, "image/*"); startActivityForResult(intent, Constant.REQUESTCODE_UPLOADAVATAR_LOCATION); } }); break; case R.id.user_center: if (Config.tUser != null) { Lock.canPop = false; startActivityForResult( new Intent(MainActivity.this, UserCenter.class).putExtra("USER", Config.tUser), 100); overridePendingTransition(R.anim.slide_in_from_left, R.anim.slide_out_to_right); } break; case R.id.user_albums: startActivityForResult(new Intent(MainActivity.this, TuyiPlayActivity.class), 100); overridePendingTransition(R.anim.slide_in_from_left, R.anim.slide_out_to_right); break; case R.id.user_setting: startActivityForResult(new Intent(MainActivity.this, MyRadarActivity.class), 100); break; case R.id.my_interested: startActivityForResult(new Intent(MainActivity.this, MyInterestedActivity.class), 100); overridePendingTransition(R.anim.slide_in_from_left, R.anim.slide_out_to_right); break; } }
From source file:com.fa.mastodon.activity.ComposeActivity.java
private void initiateCameraApp() { // We don't need to ask for permission in this case, because the used calls require // android.permission.WRITE_EXTERNAL_STORAGE only on SDKs *older* than Kitkat, which was // way before permission dialogues have been introduced. Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); if (intent.resolveActivity(getPackageManager()) != null) { File photoFile = null;/*from w w w . j a va2 s .c o m*/ try { photoFile = createNewImageFile(); } catch (IOException ex) { displayTransientError(R.string.error_media_upload_opening); } // Continue only if the File was successfully created if (photoFile != null) { photoUploadUri = FileProvider.getUriForFile(this, "com.keylesspalace.tusky.fileprovider", photoFile); intent.putExtra(MediaStore.EXTRA_OUTPUT, photoUploadUri); startActivityForResult(intent, MEDIA_TAKE_PHOTO_RESULT); } } }
From source file:com.inter.trade.ui.fragment.agent.AgentApplyFragmentNew.java
/** * ??/* w w w. j a v a2s.c o m*/ */ private void takePhoto() { // ??SD?? String SDState = Environment.getExternalStorageState(); if (SDState.equals(Environment.MEDIA_MOUNTED)) { Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);// "android.media.action.IMAGE_CAPTURE" /*** * ????? ????? * ?ContentValues????? */ ContentValues values = new ContentValues(); photoUri = getActivity().getContentResolver().insert(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, values); intent.putExtra(android.provider.MediaStore.EXTRA_OUTPUT, photoUri); /** ----------------- */ startActivityForResult(intent, SELECT_PIC_BY_TACK_PHOTO); } else { Toast.makeText(getActivity(), "??", Toast.LENGTH_LONG).show(); } }
From source file:com.cpic.taylor.logistics.activity.HomeActivity.java
/** * /* w w w . j a v a 2 s . c o m*/ */ private void getFromCamera(int type1, boolean isUser) { intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); if (isUser) { cameraPic = new File(Environment.getExternalStorageDirectory().getAbsolutePath() + "/userIcon.jpg"); } else { cameraPic = new File(Environment.getExternalStorageDirectory().getAbsolutePath() + "/carInfo.jpg"); } cameraUri = Uri.fromFile(cameraPic); // ??? intent.putExtra(MediaStore.EXTRA_OUTPUT, cameraUri); startActivityForResult(intent, type1); }
From source file:com.youti.chat.activity.ChatActivity.java
/** * ?// w ww .j a v a 2s . c om */ public void selectPicFromCamera() { if (!CommonUtils.isExitsSdcard()) { String st = getResources().getString(R.string.sd_card_does_not_exist); Toast.makeText(getApplicationContext(), st, 0).show(); return; } cameraFile = new File(PathUtil.getInstance().getImagePath(), YoutiApplication.getInstance().getUserName() + System.currentTimeMillis() + ".jpg"); cameraFile.getParentFile().mkdirs(); startActivityForResult(new Intent(MediaStore.ACTION_IMAGE_CAPTURE).putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(cameraFile)), REQUEST_CODE_CAMERA); }
From source file:org.kontalk.ui.AbstractComposeFragment.java
/** Starts an activity for shooting a picture. */ void selectPhotoAttachment() { try {//from w w w. j a va 2s . com // check if camera is available final PackageManager packageManager = getActivity().getPackageManager(); final Intent intent = SystemUtils.externalIntent(MediaStore.ACTION_IMAGE_CAPTURE); List<ResolveInfo> list = packageManager.queryIntentActivities(intent, PackageManager.MATCH_DEFAULT_ONLY); if (list.size() <= 0) throw new UnsupportedOperationException(); mCurrentPhoto = MediaStorage.getOutgoingPhotoFile(); Uri uri = Uri.fromFile(mCurrentPhoto); Intent take = SystemUtils.externalIntent(MediaStore.ACTION_IMAGE_CAPTURE); take.putExtra(MediaStore.EXTRA_OUTPUT, uri); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { take.setClipData(ClipData.newUri(getContext().getContentResolver(), "Picture path", uri)); } startActivityForResult(take, SELECT_ATTACHMENT_PHOTO); } catch (UnsupportedOperationException ue) { Toast.makeText(getActivity(), R.string.chooser_error_no_camera_app, Toast.LENGTH_LONG).show(); } catch (IOException e) { Log.e(TAG, "error creating temp file", e); Toast.makeText(getActivity(), R.string.chooser_error_no_camera, Toast.LENGTH_LONG).show(); } }