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.almalence.opencam.PluginManagerBase.java
public boolean handleApplicationMessage(Message msg) { long sessionID = 0; switch (msg.what) { case ApplicationInterface.MSG_NO_CAMERA: break;//from w w w . j a v a 2s.c o m case ApplicationInterface.MSG_CAPTURE_FINISHED: /* * Debug code for Galaxy S6 in Super mode. Look at Camera2 for more * details */ // CameraController.onCaptureFinished(); if (ApplicationScreen.instance.getFlashModePref( ApplicationScreen.sDefaultFlashValue) == CameraParameters.FLASH_MODE_CAPTURE_TORCH) { // If flashMode == FLASH_MODE_CAPTURE_TORCH, then turn off torch // after capturing completed. CameraController.setCameraFlashMode(CameraParameters.FLASH_MODE_OFF); } for (int i = 0; i < activeVF.size(); i++) pluginList.get(activeVF.get(i)).onCaptureFinished(); ApplicationScreen.getGUIManager().onCaptureFinished(); ApplicationScreen.getGUIManager().startProcessingAnimation(); int id = ApplicationScreen.getAppResources().getIdentifier(getActiveMode().modeName, "string", ApplicationScreen.instance.getPackageName()); String modeName = ApplicationScreen.getAppResources().getString(id); addToSharedMem("mode_name" + (String) msg.obj, modeName); // start async task for further processing cntProcessing++; sessionID = Long.valueOf((String) msg.obj); // Map sessionID and processing plugin, because active plugin may be // changed before image processing will start. // We don't map export plugin, because it's the same for all modes. processingPluginList.put(sessionID, pluginList.get(activeProcessing)); Intent mServiceIntent = new Intent(ApplicationScreen.instance, ProcessingService.class); // Pass to Service sessionID and some other parameters, that may be // required. mServiceIntent.putExtra("sessionID", sessionID); CameraController.Size imageSize = CameraController.getCameraImageSize(); PluginManager.getInstance().addToSharedMem("imageWidth" + sessionID, String.valueOf(imageSize.getWidth())); PluginManager.getInstance().addToSharedMem("imageHeight" + sessionID, String.valueOf(imageSize.getHeight())); PluginManager.getInstance().addToSharedMem("wantLandscapePhoto" + sessionID, String.valueOf(ApplicationScreen.getWantLandscapePhoto())); PluginManager.getInstance().addToSharedMem("cameraMirrored" + sessionID, String.valueOf(CameraController.isFrontCamera())); // Start processing service with current sessionID. ApplicationScreen.instance.startService(mServiceIntent); ApplicationScreen.instance.muteShutter(false); break; case ApplicationInterface.MSG_CAPTURE_FINISHED_NORESULT: /* * Debug code for Galaxy S6 in Super mode. Look at Camera2 for more * details */ // CameraController.onCaptureFinished(); if (ApplicationScreen.instance.getFlashModePref( ApplicationScreen.sDefaultFlashValue) == CameraParameters.FLASH_MODE_CAPTURE_TORCH) { // If flashMode == FLASH_MODE_CAPTURE_TORCH, then turn off torch // after capturing completed. CameraController.setCameraFlashMode(CameraParameters.FLASH_MODE_OFF); } for (int i = 0; i < activeVF.size(); i++) pluginList.get(activeVF.get(i)).onCaptureFinished(); ApplicationScreen.getGUIManager().onCaptureFinished(); ApplicationScreen.getGUIManager().startProcessingAnimation(); ApplicationScreen.instance.muteShutter(false); ApplicationScreen.getGUIManager().lockControls = false; sendMessage(ApplicationInterface.MSG_BROADCAST, ApplicationInterface.MSG_CONTROL_UNLOCKED); ApplicationScreen.getGUIManager().onExportFinished(); for (int i = 0; i < activeVF.size(); i++) pluginList.get(activeVF.get(i)).onExportFinished(); break; case ApplicationInterface.MSG_START_POSTPROCESSING: if (null != pluginList.get(activeProcessing)) { ApplicationScreen.getGUIManager().lockControls = true; sendMessage(ApplicationInterface.MSG_BROADCAST, ApplicationInterface.MSG_CONTROL_LOCKED); pluginList.get(activeProcessing).onStartPostProcessing(); ApplicationScreen.getGUIManager().onPostProcessingStarted(); } break; case ApplicationInterface.MSG_POSTPROCESSING_FINISHED: sessionID = 0; String sSessionID = getFromSharedMem("sessionID"); if (sSessionID != null) sessionID = Long.parseLong(getFromSharedMem("sessionID")); // notify GUI about saved images ApplicationScreen.getGUIManager().lockControls = false; sendMessage(ApplicationInterface.MSG_BROADCAST, ApplicationInterface.MSG_CONTROL_UNLOCKED); ApplicationScreen.getGUIManager().onPostProcessingFinished(); if (null != pluginList.get(activeExport) && 0 != sessionID) { pluginList.get(activeExport).onExportActive(sessionID); } else { ApplicationScreen.getMessageHandler().sendEmptyMessage(ApplicationInterface.MSG_EXPORT_FINISHED); clearSharedMemory(sessionID); } break; case ApplicationInterface.MSG_EXPORT_FINISHED: // event from plugin that saving finished and memory can be freed if (cntProcessing > 0) cntProcessing--; // free memory in processing if (null != pluginList.get(activeProcessing)) pluginList.get(activeProcessing).freeMemory(); // notify GUI about saved images ApplicationScreen.getGUIManager().onExportFinished(); // notify capture plugins that saving finished if (null != pluginList.get(activeCapture)) pluginList.get(activeCapture).onExportFinished(); for (int i = 0; i < activeVF.size(); i++) pluginList.get(activeVF.get(i)).onExportFinished(); if (ApplicationScreen.instance.getIntent().getAction() != null) { if (ApplicationScreen.instance.getIntent().getAction().equals(MediaStore.ACTION_IMAGE_CAPTURE)) { ApplicationScreen.getMessageHandler() .sendEmptyMessage(ApplicationInterface.MSG_RETURN_CAPTURED); } } ApplicationScreen.getGUIManager().lockControls = false; sendMessage(ApplicationInterface.MSG_BROADCAST, ApplicationInterface.MSG_CONTROL_UNLOCKED); break; case ApplicationInterface.MSG_EXPORT_FINISHED_IOEXCEPTION: // event from plugin that saving finished and memory can be freed if (cntProcessing > 0) cntProcessing--; // free memory in processing if (null != pluginList.get(activeProcessing)) pluginList.get(activeProcessing).freeMemory(); // notify GUI about saved images ApplicationScreen.getGUIManager().onExportFinished(); // notify capture plugins that saving finished if (null != pluginList.get(activeCapture)) pluginList.get(activeCapture).onExportFinished(); for (int i = 0; i < activeVF.size(); i++) pluginList.get(activeVF.get(i)).onExportFinished(); Toast.makeText(ApplicationScreen.getMainContext(), "Can't save data - no free space left or problems while saving occurred.", Toast.LENGTH_LONG) .show(); ApplicationScreen.getGUIManager().lockControls = false; sendMessage(ApplicationInterface.MSG_BROADCAST, ApplicationInterface.MSG_CONTROL_UNLOCKED); break; case ApplicationInterface.MSG_DELAYED_CAPTURE: for (int i = 0; i < activeVF.size(); i++) pluginList.get(activeVF.get(i)).onShutterClick(); if (null != pluginList.get(activeCapture)) pluginList.get(activeCapture).onShutterClick(); break; case ApplicationInterface.MSG_RETURN_CAPTURED: ApplicationScreen.instance.setResult(Activity.RESULT_OK); ApplicationScreen.instance.finish(); break; case ApplicationInterface.MSG_OPENGL_LAYER_SHOW: ApplicationScreen.instance.showOpenGLLayer(1); break; case ApplicationInterface.MSG_OPENGL_LAYER_SHOW_V2: ApplicationScreen.instance.showOpenGLLayer(2); break; case ApplicationInterface.MSG_OPENGL_LAYER_HIDE: ApplicationScreen.instance.hideOpenGLLayer(); break; case ApplicationInterface.MSG_OPENGL_LAYER_RENDERMODE_CONTINIOUS: ApplicationScreen.instance.glSetRenderingMode(GLSurfaceView.RENDERMODE_CONTINUOUSLY); break; case ApplicationInterface.MSG_OPENGL_LAYER_RENDERMODE_WHEN_DIRTY: ApplicationScreen.instance.glSetRenderingMode(GLSurfaceView.RENDERMODE_WHEN_DIRTY); break; case ApplicationInterface.MSG_PROCESSING_BLOCK_UI: ApplicationScreen.getGUIManager().processingBlockUI(); break; case ApplicationInterface.MSG_BROADCAST: onBroadcast(msg.arg1, msg.arg2); break; default: break; } return true; }
From source file:com.xuejian.client.lxp.module.toolbox.im.ChatActivity.java
/** * ?/*from www.j ava2 s.c om*/ */ public void selectPicFromCamera() { if (!CommonUtils.isExitsSdcard()) { // Toast.makeText(getApplicationContext(), "SD????", Toast.LENGTH_SHORT).show(); ToastUtil.getInstance(ChatActivity.this).showToast("???"); return; } cameraFile = new File(PathUtil.getInstance().getImagePath(), AccountManager.getInstance().getLoginAccount(this).easemobUser + 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:com.ccxt.whl.activity.SettingsFragment.java
/** * ?/*from w w w . j a v a2 s .c o m*/ */ public void selectPicFromCamera() { // cameraFile = new File(PathUtil.getInstance().getImagePath(), DemoApplication.getInstance().getUserName() startActivityForResult(new Intent(MediaStore.ACTION_IMAGE_CAPTURE).putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(cameraFile)), USERPIC_REQUEST_CODE_CAMERA); }
From source file:com.hzx.luoyechat.activity.ChatActivity.java
/** * ?//from w w w. j a va2 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, Toast.LENGTH_SHORT).show(); return; } cameraFile = new File(PathUtil.getInstance().getImagePath(), DemoApplication.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:cn.ucai.yizhesale.activity.ChatActivity.java
/** * ?//from w ww . j av a 2 s .co m */ public void selectPicFromCamera() { if (!CommonUtils.isExitsSdcard()) { String st = getResources().getString(cn.ucai.yizhesale.R.string.sd_card_does_not_exist); Toast.makeText(getApplicationContext(), st, Toast.LENGTH_SHORT).show(); return; } cameraFile = new File(PathUtil.getInstance().getImagePath(), YiZheSaleApplication.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:com.zhenlaidian.ui.InputCarNumberActivity.java
private void takePhoto(int num) { // ??SD??/*www.j ava2s . co m*/ Constant.ISNEEDBACKUP = false; File picFile = null; String SDState = Environment.getExternalStorageState(); if (SDState.equals(Environment.MEDIA_MOUNTED)) { File dir = new File(Environment.getExternalStorageDirectory() + "/TingCheBao"); if (!dir.exists()) { dir.mkdirs(); } SimpleDateFormat dateaf = new SimpleDateFormat("yyyyMMddHHmm"); String filename = dateaf.format(System.currentTimeMillis()) + num + ".jpeg"; picFile = new File(dir.getAbsolutePath(), filename); files.add(picFile); MyLog.i("INCarDialogActivity", "picFile=" + picFile); Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); intent.putExtra(MediaStore.Images.Media.ORIENTATION, 0); intent.putExtra(android.provider.MediaStore.EXTRA_OUTPUT, Uri.fromFile(picFile)); intent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT); startActivityForResult(intent, 10); MyLog.i("INCarDialogActivity", "startActivityForResult(intent, 10)"); // ??1?onActivityResultrequestCode0??? } else { Toast.makeText(this, "??", Toast.LENGTH_LONG).show(); } }
From source file:info.guardianproject.otr.app.im.app.NewChatActivity.java
void startPhotoTaker() { // create Intent to take a picture and return control to the calling application Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); File photo = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DCIM), "cs_" + new Date().getTime() + ".jpg"); mLastPhoto = Uri.fromFile(photo);/*from www . jav a 2 s .c om*/ intent.putExtra(MediaStore.EXTRA_OUTPUT, mLastPhoto); // start the image capture Intent startActivityForResult(intent, REQUEST_TAKE_PICTURE); }
From source file:cn.ucai.fulicenter.activity.ChatActivity.java
/** * ?//from ww w . j a va 2 s . c om */ public void selectPicFromCamera() { if (!CommonUtils.isExitsSdcard()) { String st = getResources().getString(R.string.sd_card_does_not_exist); Toast.makeText(getApplicationContext(), st, Toast.LENGTH_SHORT).show(); return; } cameraFile = new File(PathUtil.getInstance().getImagePath(), FuLiCenterApplication.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:cn.gen.superwechat.activity.ChatActivity.java
/** * ?/* w ww .j a va 2s .co m*/ */ public void selectPicFromCamera() { if (!CommonUtils.isExitsSdcard()) { String st = getResources().getString(cn.gen.superwechat.R.string.sd_card_does_not_exist); Toast.makeText(getApplicationContext(), st, Toast.LENGTH_SHORT).show(); return; } cameraFile = new File(PathUtil.getInstance().getImagePath(), SuperWeChatApplication.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); }