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:hku.fyp14017.blencode.ui.dialogs.NewSpriteDialog.java
private void setupCameraButton(View parentView) { View cameraButton = parentView.findViewById(hku.fyp14017.blencode.R.id.dialog_new_object_camera); cameraButton.setOnClickListener(new View.OnClickListener() { @Override// w w w. java 2 s. c om public void onClick(View view) { lookUri = UtilCamera .getDefaultLookFromCameraUri(getString(hku.fyp14017.blencode.R.string.default_look_name)); Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); intent.putExtra(MediaStore.EXTRA_OUTPUT, lookUri); startActivityForResult(intent, REQUEST_TAKE_PICTURE); } }); }
From source file:com.zhaojian.jolly.fragment.UserPhotosFragment.java
private void takePhoto() { if (null == mPhotoFile) { Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); mPhotoFile = Utils.getCameraPhotoFile(); takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(mPhotoFile)); startActivityForResult(takePictureIntent, RESULT_CAMERA); }//from w w w. j ava 2 s . c o m }
From source file:io.v.moments.ux.MainActivity.java
/** * Before calling this, must have permission to read/write to storage, to * read/write photo data. Don't need camera permission, since a new activity * is started to actually take the photo. *//*from w w w . jav a 2s .c o m*/ private void takePhoto() { Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); mCurrentPhotoId = Id.makeRandom(); Integer ordinal = mLocalMoments.size() + 1; Uri uri = mBitMapper.getCameraPhotoUri(ordinal); intent.putExtra(MediaStore.EXTRA_OUTPUT, uri); startActivityForResult(intent, RequestCode.CAPTURE_IMAGE); }
From source file:com.company.millenium.iwannask.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); //GPS//from w w w.j a v a 2s.c o m locationManager = (LocationManager) this.getSystemService(Context.LOCATION_SERVICE); locationListener = new LocationListener() { public void onLocationChanged(Location location) { if (ActivityCompat.checkSelfPermission(MainActivity.this, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED) { // Check Permissions Now final int REQUEST_LOCATION = 2; if (ActivityCompat.shouldShowRequestPermissionRationale(MainActivity.this, Manifest.permission.ACCESS_FINE_LOCATION)) { // Display UI and wait for user interaction } else { ActivityCompat.requestPermissions(MainActivity.this, new String[] { Manifest.permission.ACCESS_FINE_LOCATION }, REQUEST_LOCATION); } } else { locationManager.removeUpdates(this); } } public void onStatusChanged(String string, int integer, Bundle bundle) { } public void onProviderEnabled(String string) { } public void onProviderDisabled(String string) { } }; if (ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED) { // Check Permissions Now final int REQUEST_LOCATION = 2; if (ActivityCompat.shouldShowRequestPermissionRationale(this, Manifest.permission.ACCESS_FINE_LOCATION)) { // Display UI and wait for user interaction } else { ActivityCompat.requestPermissions(this, new String[] { Manifest.permission.ACCESS_FINE_LOCATION }, REQUEST_LOCATION); } } else { locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 1000, 1000, locationListener); } int delay = 30000; // delay for 30 sec. int period = 3000000; // repeat every 5.3min. Timer timer = new Timer(); timer.scheduleAtFixedRate(new TimerTask() { public void run() { if (ActivityCompat.checkSelfPermission(MainActivity.this, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED) { // Check Permissions Now final int REQUEST_LOCATION = 2; if (ActivityCompat.shouldShowRequestPermissionRationale(MainActivity.this, Manifest.permission.ACCESS_FINE_LOCATION)) { // Display UI and wait for user interaction } else { ActivityCompat.requestPermissions(MainActivity.this, new String[] { Manifest.permission.ACCESS_FINE_LOCATION }, REQUEST_LOCATION); } } else { locationManager.removeUpdates(locationListener); } } }, delay, period); getWindow().addFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN); Intent mIntent = getIntent(); URL = Constants.SERVER_URL; if (mIntent.hasExtra("url")) { myWebView = null; startActivity(getIntent()); String url = mIntent.getStringExtra("url"); URL = Constants.SERVER_URL + url; } CookieSyncManager.createInstance(this); CookieSyncManager.getInstance().startSync(); myWebView = (WebView) findViewById(R.id.webview); myWebView.getSettings().setGeolocationDatabasePath(this.getFilesDir().getPath()); myWebView.getSettings().setGeolocationEnabled(true); WebSettings webSettings = myWebView.getSettings(); webSettings.setUseWideViewPort(false); if (!DetectConnection.checkInternetConnection(this)) { webSettings.setCacheMode(WebSettings.LOAD_CACHE_ELSE_NETWORK); showNoConnectionDialog(this); } else { webSettings.setCacheMode(WebSettings.LOAD_DEFAULT); } webSettings.setJavaScriptEnabled(true); myWebView.addJavascriptInterface(new webappinterface(this), "android"); webSettings.setLoadWithOverviewMode(true); webSettings.setUseWideViewPort(true); myWebView.setOverScrollMode(View.OVER_SCROLL_NEVER); //location test webSettings.setAppCacheEnabled(true); webSettings.setDatabaseEnabled(true); webSettings.setDomStorageEnabled(true); myWebView.setWebViewClient(new WebViewClient() { @Override public void onPageFinished(WebView view, String url) { CookieSyncManager.getInstance().sync(); } @Override public void onReceivedSslError(WebView view, SslErrorHandler handler, SslError error) { handler.proceed(); // Ignore SSL certificate errors } @Override public boolean shouldOverrideUrlLoading(WebView view, String url) { if (Uri.parse(url).getHost().equals(Constants.HOST) || Uri.parse(url).getHost().equals(Constants.WWWHOST)) { // This is my web site, so do not override; let my WebView load // the page return false; } // Otherwise, the link is not for a page on my site, so launch // another Activity that handles URLs Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url)); startActivity(intent); return true; } }); myWebView.setWebChromeClient(new WebChromeClient() { public void onGeolocationPermissionsShowPrompt(String origin, GeolocationPermissions.Callback callback) { callback.invoke(origin, true, false); } @Override public void onPermissionRequest(final PermissionRequest request) { Log.d(TAG, "onPermissionRequest"); runOnUiThread(new Runnable() { @TargetApi(Build.VERSION_CODES.LOLLIPOP) @Override public void run() { if (request.getOrigin().toString().equals("https://apprtc-m.appspot.com/")) { request.grant(request.getResources()); } else { request.deny(); } } }); } public boolean onShowFileChooser(WebView webView, ValueCallback<Uri[]> filePathCallback, WebChromeClient.FileChooserParams fileChooserParams) { // Double check that we don't have any existing callbacks if (mFilePathCallback != null) { mFilePathCallback.onReceiveValue(null); } mFilePathCallback = filePathCallback; // Set up the take picture intent Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); if (takePictureIntent.resolveActivity(getPackageManager()) != null) { // Create the File where the photo should go File photoFile = null; try { photoFile = createImageFile(); takePictureIntent.putExtra("PhotoPath", mCameraPhotoPath); } catch (IOException ex) { // Error occurred while creating the File Log.e(TAG, "Unable to create Image File", ex); } // Continue only if the File was successfully created if (photoFile != null) { mCameraPhotoPath = "file:" + photoFile.getAbsolutePath(); takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(photoFile)); } else { takePictureIntent = null; } } // Set up the intent to get an existing image Intent contentSelectionIntent = new Intent(Intent.ACTION_GET_CONTENT); contentSelectionIntent.addCategory(Intent.CATEGORY_OPENABLE); contentSelectionIntent.setType("image/*"); // Set up the intents for the Intent chooser Intent[] intentArray; if (takePictureIntent != null) { intentArray = new Intent[] { takePictureIntent }; } else { intentArray = new Intent[0]; } Intent chooserIntent = new Intent(Intent.ACTION_CHOOSER); chooserIntent.putExtra(Intent.EXTRA_INTENT, contentSelectionIntent); chooserIntent.putExtra(Intent.EXTRA_TITLE, "Image Chooser"); chooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS, intentArray); startActivityForResult(chooserIntent, INPUT_FILE_REQUEST_CODE); return true; } }); // setContentView(myWebView); // myWebView.loadUrl(URL); myWebView.loadUrl(URL); mRegistrationBroadcastReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { // mRegistrationProgressBar.setVisibility(ProgressBar.GONE); SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context); boolean sentToken = sharedPreferences.getBoolean(QuickstartPreferences.SENT_TOKEN_TO_SERVER, false); } }; //CookieManager mCookieManager = CookieManager.getInstance(); //Boolean hasCookies = mCookieManager.hasCookies(); //while(!hasCookies); if (checkPlayServices()) { // Start IntentService to register this application with GCM. Intent intent = new Intent(this, RegistrationIntentService.class); //intent.putExtra("session", session); startService(intent); } Boolean isFirstRun = getSharedPreferences("PREFERENCE", MODE_PRIVATE).getBoolean("isFirstRun", true); if (isFirstRun) { //show start activity startActivity(new Intent(MainActivity.this, MyIntro.class)); } //if (!isOnline()) // showNoConnectionDialog(this); getSharedPreferences("PREFERENCE", MODE_PRIVATE).edit().putBoolean("isFirstRun", false).commit(); //Pull-to-refresh mSwipeRefreshLayout = (SwipeRefreshLayout) findViewById(R.id.container); mSwipeRefreshLayout.setOnRefreshListener(this); }
From source file:cn.com.caronwer.activity.CertificationActivity.java
@Override public void onRequestPermissionsResult(int requestCode, String permissions[], int[] grantResults) { switch (requestCode) { case 100: {/*from w w w . java 2s . co m*/ if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) { Intent takeIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); //???? takeIntent.putExtra(MediaStore.EXTRA_OUTPUT, Uri .fromFile(new File(Environment.getExternalStorageDirectory(), IMAGE_FILE_NAME[imgType]))); startActivityForResult(takeIntent, REQUESTCODE_TAKE); } else { Toast.makeText(CertificationActivity.this, "Permission Denied", Toast.LENGTH_SHORT).show(); } return; } case 200: { if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) { Intent pickIntent = new Intent(Intent.ACTION_PICK, null); pickIntent.setDataAndType(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, "image/*"); startActivityForResult(pickIntent, REQUESTCODE_PICK); } else { Toast.makeText(CertificationActivity.this, "Permission Denied", Toast.LENGTH_SHORT).show(); } return; } case 300: { if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) { //getServletData(); } else { Toast.makeText(CertificationActivity.this, "Permission Denied", Toast.LENGTH_SHORT).show(); } return; } } super.onRequestPermissionsResult(requestCode, permissions, grantResults); }
From source file:nazmul.storagesampletest.MainActivity.java
public void launchCamera(View view) { Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); // Ensure that there's a camera activity to handle the intent if (takePictureIntent.resolveActivity(getPackageManager()) != null) { // Create the File where the photo should go File photoFile = null;//from w ww. ja va 2 s.c om try { photoFile = createImageFile(); } catch (IOException ex) { Toast.makeText(this, ex.getMessage(), Toast.LENGTH_SHORT).show(); } // Continue only if the File was successfully created if (photoFile != null) { takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(photoFile)); startActivityForResult(takePictureIntent, REQUEST_IMAGE_CAPTURE); } } }
From source file:com.pawnua.android.app.gpstrips.activities.TripDetailActivity.java
private void takePhoto() { Intent callCameraApplicationIntent = new Intent(); callCameraApplicationIntent.setAction(MediaStore.ACTION_IMAGE_CAPTURE); try {//from ww w. j a v a 2 s . com photoFile = GalleryDataManager.createImageFile(mGalleryFolder); } catch (IOException e) { e.printStackTrace(); } callCameraApplicationIntent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(photoFile)); startActivityForResult(callCameraApplicationIntent, ACTIVITY_START_CAMERA_APP); }
From source file:com.fvd.nimbus.MainActivity.java
public void getPhoto() { try {/*from ww w .ja va 2s .co m*/ photoFileName = String.valueOf(System.currentTimeMillis()) + "-tmp.jpg"; Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); File file = new File(appSettings.getInstance().SavingPath, photoFileName); outputFileUri = Uri.fromFile(file); intent.putExtra(MediaStore.EXTRA_OUTPUT, outputFileUri); startActivityForResult(intent, TAKE_PHOTO); //overridePendingTransition( R.anim.slide_in_up, R.anim.slide_out_up ); overridePendingTransition(R.anim.carbon_slide_in, R.anim.carbon_slide_out); } catch (Exception e) { appSettings.appendLog("main:getPhoto " + e.getMessage()); } }
From source file:com.liwn.zzl.markbit.DrawOptionsMenuActivity.java
protected void takePhoto() { File tempFile = FileIO.createNewEmptyPictureFile(DrawOptionsMenuActivity.this, FileIO.getDefaultFileName()); if (tempFile != null) { mCameraImageUri = Uri.fromFile(tempFile); }/*from w w w. java 2 s . c o m*/ if (mCameraImageUri == null) { new InfoDialog(DialogType.WARNING, R.string.dialog_error_sdcard_text, R.string.dialog_error_save_title) .show(getSupportFragmentManager(), "savedialogerror"); return; } // Intent intent = new Intent("android.media.action.IMAGE_CAPTURE"); Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); intent.putExtra(MediaStore.EXTRA_OUTPUT, mCameraImageUri); intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET); startActivityForResult(intent, REQUEST_CODE_TAKE_PICTURE); // intent.putExtra(MediaStore.EXTRA_OUTPUT, mCameraImageUri); // intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET); // startActivityForResult(intent, REQUEST_CODE_TAKE_PICTURE); }
From source file:com.bf.zxd.zhuangxudai.my.fragment.FinancialApplyFragment.java
private void ChangeIcon() { //PopupWindow----START-----??PopupWindowPopupWindow??? backgroundAlpha(0.3f);/* w w w . ja va 2s. c o m*/ View view = LayoutInflater.from(getActivity().getBaseContext()).inflate(R.layout.popu_window, null); final PopupWindow popupWindow = new PopupWindow(view, ActionBar.LayoutParams.WRAP_CONTENT, ActionBar.LayoutParams.WRAP_CONTENT, true); popupWindow.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT)); popupWindow.setOutsideTouchable(true); popupWindow.setFocusable(true); //?? DisplayMetrics dm = new DisplayMetrics(); getActivity().getWindowManager().getDefaultDisplay().getMetrics(dm); popupWindow.setWidth(dm.widthPixels); popupWindow.setAnimationStyle(R.style.popuwindow); //? popupWindow.showAtLocation(view, Gravity.BOTTOM, 0, 0); popupWindow.setOnDismissListener(new poponDismissListener_FinancialApplyFragment()); //PopupWindow-----END //PopupWindow Button button = (Button) view.findViewById(R.id.take_photo);//?? Button button1 = (Button) view.findViewById(R.id.all_photo);//? Button button2 = (Button) view.findViewById(R.id.out);//? button2.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { backgroundAlpha(1f); popupWindow.dismiss(); } }); button1.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { backgroundAlpha(1f); popupWindow.dismiss(); //,? allPhoto(); } }); button.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { backgroundAlpha(1f); popupWindow.dismiss(); //,Intent???? Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); //,?? File file = FileUitlity.getInstance(getActivity().getApplicationContext()).makeDir("head_image"); //?? path = file.getParent() + File.separatorChar + System.currentTimeMillis() + ".jpg"; //?IntentIntent? intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(new File(path))); //? intent.putExtra(MediaStore.EXTRA_VIDEO_QUALITY, 1); //?Intent??RoundImageView startActivityForResult(intent, REQUEST_CODE); } }); }