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.example.vedantn.algaeestimator.MainActivity.java
public void takePicture(View view) { Intent cameraIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); startActivityForResult(cameraIntent, CAMERA_REQUEST_CODE); }
From source file:foam.littlej.android.app.ui.phone.AddReportActivity.java
/** * Create various dialog//w w w .ja v a2s .c om */ @Override protected Dialog onCreateDialog(int id) { switch (id) { case DIALOG_ERROR_NETWORK: { AlertDialog dialog = (new AlertDialog.Builder(this)).create(); dialog.setTitle(getString(R.string.network_error)); dialog.setMessage(getString(R.string.network_error_msg)); dialog.setButton2(getString(R.string.ok), new Dialog.OnClickListener() { public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); dialog.setCancelable(false); return dialog; } case DIALOG_ERROR_SAVING: { AlertDialog dialog = (new AlertDialog.Builder(this)).create(); dialog.setTitle(getString(R.string.network_error)); dialog.setMessage(getString(R.string.file_system_error_msg)); dialog.setButton2(getString(R.string.ok), new Dialog.OnClickListener() { public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); dialog.setCancelable(false); return dialog; } case DIALOG_CHOOSE_IMAGE_METHOD: { AlertDialog dialog = (new AlertDialog.Builder(this)).create(); dialog.setTitle(getString(R.string.choose_method)); dialog.setMessage(getString(R.string.how_to_select_pic)); dialog.setButton(getString(R.string.gallery_option), new Dialog.OnClickListener() { public void onClick(DialogInterface dialog, int which) { Intent intent = new Intent(); intent.setAction(Intent.ACTION_PICK); intent.setData(MediaStore.Images.Media.EXTERNAL_CONTENT_URI); startActivityForResult(intent, REQUEST_CODE_IMAGE); dialog.dismiss(); } }); dialog.setButton2(getString(R.string.cancel), new Dialog.OnClickListener() { public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); dialog.setButton3(getString(R.string.camera_option), new Dialog.OnClickListener() { public void onClick(DialogInterface dialog, int which) { Intent intent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE); intent.putExtra(MediaStore.EXTRA_OUTPUT, PhotoUtils.getPhotoUri(photoName, AddReportActivity.this)); startActivityForResult(intent, REQUEST_CODE_CAMERA); dialog.dismiss(); } }); dialog.setCancelable(false); return dialog; } case DIALOG_MULTIPLE_CATEGORY: { if (showCategories() != null) { return new AlertDialog.Builder(this).setTitle(R.string.choose_categories) .setMultiChoiceItems(showCategories(), setCheckedCategories(), new DialogInterface.OnMultiChoiceClickListener() { public void onClick(DialogInterface dialog, int whichButton, boolean isChecked) { // see if categories have previously if (isChecked) { mVectorCategories.add(mCategoriesId.get(whichButton)); mError = false; } else { mVectorCategories.remove(mCategoriesId.get(whichButton)); } setSelectedCategories(mVectorCategories); } }) .setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { /* User clicked Yes so do some stuff */ } }).create(); } } case TIME_DIALOG_ID: return new TimePickerDialog(this, mTimeSetListener, mCalendar.get(Calendar.HOUR), mCalendar.get(Calendar.MINUTE), false); case DATE_DIALOG_ID: return new DatePickerDialog(this, mDateSetListener, mCalendar.get(Calendar.YEAR), mCalendar.get(Calendar.MONTH), mCalendar.get(Calendar.DAY_OF_MONTH)); case DIALOG_SHOW_MESSAGE: AlertDialog.Builder messageBuilder = new AlertDialog.Builder(this); messageBuilder.setMessage(mErrorMessage).setPositiveButton(getString(R.string.ok), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.cancel(); } }); AlertDialog showDialog = messageBuilder.create(); showDialog.show(); break; case DIALOG_SHOW_REQUIRED: AlertDialog.Builder requiredBuilder = new AlertDialog.Builder(this); requiredBuilder.setTitle(R.string.required_fields); requiredBuilder.setMessage(mErrorMessage).setPositiveButton(getString(R.string.ok), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.cancel(); } }); AlertDialog showRequiredDialog = requiredBuilder.create(); showRequiredDialog.show(); break; // prompt for unsaved changes case DIALOG_SHOW_PROMPT: { AlertDialog dialog = (new AlertDialog.Builder(this)).create(); dialog.setTitle(getString(R.string.unsaved_changes)); dialog.setMessage(getString(R.string.want_to_cancel)); dialog.setButton(getString(R.string.no), new Dialog.OnClickListener() { public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); dialog.setButton2(getString(R.string.yes), new Dialog.OnClickListener() { public void onClick(DialogInterface dialog, int which) { new DiscardTask(AddReportActivity.this).execute((String) null); finish(); dialog.dismiss(); } }); dialog.setCancelable(false); return dialog; } // prompt for report deletion case DIALOG_SHOW_DELETE_PROMPT: { AlertDialog dialog = (new AlertDialog.Builder(this)).create(); dialog.setTitle(getString(R.string.delete_report)); dialog.setMessage(getString(R.string.want_to_delete)); dialog.setButton(getString(R.string.no), new Dialog.OnClickListener() { public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); dialog.setButton2(getString(R.string.yes), new Dialog.OnClickListener() { public void onClick(DialogInterface dialog, int which) { // delete report deleteReport(); dialog.dismiss(); } }); dialog.setCancelable(false); return dialog; } } return null; }
From source file:org.catrobat.catroid.ui.fragment.LookFragment.java
public void addLookFromCamera() { lookFromCameraUri = UtilCamera.getDefaultLookFromCameraUri(getString(R.string.default_look_name)); Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); intent.putExtra(MediaStore.EXTRA_OUTPUT, lookFromCameraUri); Intent chooser = Intent.createChooser(intent, getString(R.string.select_look_from_camera)); startActivityForResult(chooser, LookController.REQUEST_TAKE_PICTURE); }
From source file:com.example.zf_android.activity.MerchantEdit.java
private void show3Dialog(int type, final String uri) { AlertDialog.Builder builder = new AlertDialog.Builder(MerchantEdit.this); final String[] items = getResources().getStringArray(R.array.apply_detail_view); MerchantEdit.this.type = type; builder.setItems(items, new DialogInterface.OnClickListener() { @Override/*from w ww . j av a 2 s .c o m*/ public void onClick(DialogInterface dialog, int which) { switch (which) { case 0: { AlertDialog.Builder build = new AlertDialog.Builder(MerchantEdit.this); LayoutInflater factory = LayoutInflater.from(MerchantEdit.this); final View textEntryView = factory.inflate(R.layout.show_view, null); build.setView(textEntryView); final ImageView view = (ImageView) textEntryView.findViewById(R.id.imag); // ImageCacheUtil.IMAGE_CACHE.get(uri, view); ImageLoader.getInstance().displayImage(uri, view, options); build.create().show(); break; } case 1: { Intent intent; if (Build.VERSION.SDK_INT < 19) { intent = new Intent(Intent.ACTION_GET_CONTENT); intent.setType("image/*"); } else { intent = new Intent(Intent.ACTION_PICK, android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI); } startActivityForResult(intent, REQUEST_UPLOAD_IMAGE); break; } case 2: { String state = Environment.getExternalStorageState(); if (state.equals(Environment.MEDIA_MOUNTED)) { Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); File outDir = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES); if (!outDir.exists()) { outDir.mkdirs(); } File outFile = new File(outDir, System.currentTimeMillis() + ".jpg"); photoPath = outFile.getAbsolutePath(); intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(outFile)); intent.putExtra(MediaStore.EXTRA_VIDEO_QUALITY, 1); startActivityForResult(intent, REQUEST_TAKE_PHOTO); } else { CommonUtil.toastShort(MerchantEdit.this, getString(R.string.toast_no_sdcard)); } break; } } } }); builder.show(); }
From source file:com.annanovas.bestprice.DashBoardEditActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_dash_board_edit); Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar);/*from ww w.jav a2s . co m*/ ActionBar actionBar = getSupportActionBar(); if (actionBar != null) { actionBar.setHomeButtonEnabled(true); actionBar.setDisplayHomeAsUpEnabled(true); } // chosenBrandList.add(new ArrayList<String>()); // chosenBrandList.add(new ArrayList<String>()); // chosenBrandList.add(new ArrayList<String>()); etAddress = (EditText) findViewById(R.id.et_address); etEmail = (EditText) findViewById(R.id.et_email); etShopName = (EditText) findViewById(R.id.et_shop_name); etDrivingLicense = (EditText) findViewById(R.id.et_driving_licence); etNid = (EditText) findViewById(R.id.et_nid); etExperience = (EditText) findViewById(R.id.et_experience); etFirstName = (EditText) findViewById(R.id.et_first_name); etMiddleName = (EditText) findViewById(R.id.et_middle_name); etLastName = (EditText) findViewById(R.id.et_last_name); etPhoneNumber = (EditText) findViewById(R.id.et_phone); tvAddress = (TextView) findViewById(R.id.tv_address); tvArea = (TextView) findViewById(R.id.tv_area); tvDealerShip = (LinearLayout) findViewById(R.id.tv_dealership); tvDealerShipWith = (TextView) findViewById(R.id.tv_dealership_content); tvSelectedProduct = (TextView) findViewById(R.id.tv_select_product_content); tvProduct = (LinearLayout) findViewById(R.id.tv_select_product); buttonSubmit = (Button) findViewById(R.id.button_submit); areaLayout = (LinearLayout) findViewById(R.id.layout_area); brandLayout = (LinearLayout) findViewById(R.id.layout_brand); productLayout = (LinearLayout) findViewById(R.id.layout_product); layoutCamera = (LinearLayout) findViewById(R.id.layout_camera); layoutGallery = (LinearLayout) findViewById(R.id.layout_gallery); userImage = (ImageView) findViewById(R.id.iv_user_image); areaRecyclerView = (RecyclerView) findViewById(R.id.recycler_view_area); brandRecyclerView = (RecyclerView) findViewById(R.id.recycler_view_brand); productRecyclerView = (RecyclerView) findViewById(R.id.recycler_view_product); etProductSearch = (EditText) findViewById(R.id.et_product_name); etBrandSearch = (EditText) findViewById(R.id.et_brand_name); etAreaSearch = (EditText) findViewById(R.id.et_area_name); layoutSearchArea = (LinearLayout) findViewById(R.id.layout_search_area); layoutSearchProduct = (LinearLayout) findViewById(R.id.layout_search_product); layoutSearchBrand = (LinearLayout) findViewById(R.id.layout_search_brand); tvSelectedBrand = (TextView) findViewById(R.id.tv_selected_brand); tvSelectedArea = (TextView) findViewById(R.id.tv_setect_area); ivArrow1 = (ImageView) findViewById(R.id.iv_arrow1); ivArrow2 = (ImageView) findViewById(R.id.iv_arrow2); ivArrow3 = (ImageView) findViewById(R.id.iv_arrow3); ivArrow4 = (ImageView) findViewById(R.id.iv_arrow4); myDB = MyDatabaseManager.getInstance(getApplicationContext()); sharedPreferences = getSharedPreferences(AppGlobal.MY_PREFS_NAME, MODE_PRIVATE); userType = sharedPreferences.getInt("user_type", 1); int imageDimen = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_PX, getResources().getDimension(R.dimen.size_150dp), getResources().getDisplayMetrics()); myDB.open(); Cursor cursor = myDB.getUserInfo(userType, sharedPreferences.getString("user_phone_number", "")); if (userType == AppGlobal.CAR_OWNER) { userImage.setImageResource(R.drawable.ic_car_owner); tvAddress.setVisibility(View.VISIBLE); etAddress.setVisibility(View.VISIBLE); tvArea.setVisibility(View.VISIBLE); areaLayout.setVisibility(View.VISIBLE); if (!cursor.isLast()) { while (cursor.moveToNext()) { etFirstName.setText(cursor.getString(cursor.getColumnIndex("firstname"))); etMiddleName.setText(cursor.getString(cursor.getColumnIndex("middlename"))); etLastName.setText(cursor.getString(cursor.getColumnIndex("lastname"))); if (cursor.getString(cursor.getColumnIndex("address")) != null && !cursor.getString(cursor.getColumnIndex("address")).equals("null")) { etAddress.setText(cursor.getString(cursor.getColumnIndex("address"))); } etPhoneNumber.setText(cursor.getString(cursor.getColumnIndex("phone"))); etEmail.setText(cursor.getString(cursor.getColumnIndex("email"))); etShopName.setText(cursor.getString(cursor.getColumnIndex("shopname"))); areaId = cursor.getInt(cursor.getColumnIndex("area_id")); if (areaId != 0) { tvSelectedArea.setText(myDB.getAreaName(areaId)); } else { tvSelectedArea.setText(getResources().getString(R.string.select_area)); } if (cursor.getString(cursor.getColumnIndex("image")) != null && !cursor.getString(cursor.getColumnIndex("image")).equals("null")) { Glide.with(getApplicationContext()) .load(AppGlobal.userImagePath + cursor.getString(cursor.getColumnIndex("image"))) .error(R.drawable.ic_supplier).dontAnimate().override(imageDimen, imageDimen) .into(userImage); } else { userImage.setImageResource(R.drawable.ic_car_owner); } } } cursor.close(); generateAreaRecyclerView(); } else if (userType == AppGlobal.SUPPLIER) { tvAddress.setVisibility(View.VISIBLE); etAddress.setVisibility(View.VISIBLE); tvDealerShip.setVisibility(View.VISIBLE); tvProduct.setVisibility(View.VISIBLE); tvArea.setVisibility(View.VISIBLE); brandLayout.setVisibility(View.VISIBLE); productLayout.setVisibility(View.VISIBLE); areaLayout.setVisibility(View.VISIBLE); etShopName.setVisibility(View.VISIBLE); if (!cursor.isLast()) { while (cursor.moveToNext()) { etFirstName.setText(cursor.getString(cursor.getColumnIndex("firstname"))); etMiddleName.setText(cursor.getString(cursor.getColumnIndex("middlename"))); etLastName.setText(cursor.getString(cursor.getColumnIndex("lastname"))); etPhoneNumber.setText(cursor.getString(cursor.getColumnIndex("phone"))); etEmail.setText(cursor.getString(cursor.getColumnIndex("email"))); etShopName.setText(cursor.getString(cursor.getColumnIndex("shopname"))); etAddress.setText(cursor.getString(cursor.getColumnIndex("address"))); areaId = cursor.getInt(cursor.getColumnIndex("area_id")); if (areaId != 0) { tvSelectedArea.setText(myDB.getAreaName(areaId)); } else { tvSelectedArea.setText(getResources().getString(R.string.select_area)); } selectedProductIdList = myDB.getSelectedProductList(cursor.getInt(cursor.getColumnIndex("id"))); chosenBrandIdList = myDB.getSelectedBrandList(cursor.getInt(cursor.getColumnIndex("id"))); if (cursor.getString(cursor.getColumnIndex("image")) != null && !cursor.getString(cursor.getColumnIndex("image")).equals("null")) { Glide.with(getApplicationContext()) .load(AppGlobal.userImagePath + cursor.getString(cursor.getColumnIndex("image"))) .error(R.drawable.ic_supplier).dontAnimate().override(imageDimen, imageDimen) .into(userImage); } else { userImage.setImageResource(R.drawable.ic_supplier); } } } cursor.close(); generateAreaRecyclerView(); generateProductRecyclerView(); } else if (userType == AppGlobal.DRIVER) { etDrivingLicense.setVisibility(View.VISIBLE); etNid.setVisibility(View.VISIBLE); etExperience.setVisibility(View.VISIBLE); if (!cursor.isLast()) { while (cursor.moveToNext()) { etFirstName.setText(cursor.getString(cursor.getColumnIndex("firstname"))); etMiddleName.setText(cursor.getString(cursor.getColumnIndex("middlename"))); etLastName.setText(cursor.getString(cursor.getColumnIndex("lastname"))); etAddress.setText(cursor.getString(cursor.getColumnIndex("address"))); etPhoneNumber.setText(cursor.getString(cursor.getColumnIndex("phone"))); etEmail.setText(cursor.getString(cursor.getColumnIndex("email"))); etDrivingLicense.setText(cursor.getString(cursor.getColumnIndex("drivinglicence"))); etNid.setText(cursor.getString(cursor.getColumnIndex("nid"))); etExperience.setText(cursor.getString(cursor.getColumnIndex("yearofexperience"))); if (cursor.getString(cursor.getColumnIndex("image")) != null && !cursor.getString(cursor.getColumnIndex("image")).equals("null")) { Glide.with(getApplicationContext()) .load(AppGlobal.userImagePath + cursor.getString(cursor.getColumnIndex("image"))) .error(R.drawable.ic_supplier).dontAnimate().override(imageDimen, imageDimen) .into(userImage); } else { userImage.setImageResource(R.drawable.ic_car_owner); } } } cursor.close(); } else if (userType == AppGlobal.SHOP_WORKER) { etShopName.setVisibility(View.VISIBLE); etNid.setVisibility(View.VISIBLE); if (!cursor.isLast()) { while (cursor.moveToNext()) { etFirstName.setText(cursor.getString(cursor.getColumnIndex("firstname"))); etMiddleName.setText(cursor.getString(cursor.getColumnIndex("middlename"))); etLastName.setText(cursor.getString(cursor.getColumnIndex("lastname"))); etAddress.setText(cursor.getString(cursor.getColumnIndex("address"))); etPhoneNumber.setText(cursor.getString(cursor.getColumnIndex("phone"))); etEmail.setText(cursor.getString(cursor.getColumnIndex("email"))); etShopName.setText(cursor.getString(cursor.getColumnIndex("shopname"))); etNid.setText(cursor.getString(cursor.getColumnIndex("nid"))); if (cursor.getString(cursor.getColumnIndex("image")) != null && !cursor.getString(cursor.getColumnIndex("image")).equals("null")) { Glide.with(getApplicationContext()) .load(AppGlobal.userImagePath + cursor.getString(cursor.getColumnIndex("image"))) .error(R.drawable.ic_supplier).dontAnimate().override(imageDimen, imageDimen) .into(userImage); } else { userImage.setImageResource(R.drawable.ic_car_owner); } } } cursor.close(); } myDB.close(); areaLayout.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { if (layoutSearchArea.getVisibility() == View.GONE) { layoutSearchArea.setVisibility(View.VISIBLE); areaRecyclerView.setVisibility(View.VISIBLE); ivArrow2.setImageDrawable( ContextCompat.getDrawable(getApplicationContext(), R.drawable.ic_up_arrow)); } else { layoutSearchArea.setVisibility(View.GONE); areaRecyclerView.setVisibility(View.GONE); ivArrow2.setImageDrawable( ContextCompat.getDrawable(getApplicationContext(), R.drawable.ic_down_arrow)); } } }); brandLayout.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { if (selectedProductIdList.size() == 0) { Toast.makeText(getApplicationContext(), R.string.add_product, Toast.LENGTH_SHORT).show(); return; } if (layoutSearchBrand.getVisibility() == View.GONE) { layoutSearchBrand.setVisibility(View.VISIBLE); brandRecyclerView.setVisibility(View.VISIBLE); ivArrow3.setImageDrawable( ContextCompat.getDrawable(getApplicationContext(), R.drawable.ic_up_arrow)); } else { layoutSearchBrand.setVisibility(View.GONE); brandRecyclerView.setVisibility(View.GONE); ivArrow3.setImageDrawable( ContextCompat.getDrawable(getApplicationContext(), R.drawable.ic_down_arrow)); } } }); productLayout.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { if (layoutSearchProduct.getVisibility() == View.GONE) { layoutSearchProduct.setVisibility(View.VISIBLE); productRecyclerView.setVisibility(View.VISIBLE); ivArrow1.setImageDrawable( ContextCompat.getDrawable(getApplicationContext(), R.drawable.ic_up_arrow)); } else { layoutSearchProduct.setVisibility(View.GONE); productRecyclerView.setVisibility(View.GONE); ivArrow1.setImageDrawable( ContextCompat.getDrawable(getApplicationContext(), R.drawable.ic_down_arrow)); } } }); layoutCamera.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { try { Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); File file = createImageFile(); imageUri = String.valueOf(file); // showLog(imageUri); Uri photoURI = FileProvider.getUriForFile(getApplicationContext(), BuildConfig.APPLICATION_ID + ".provider", file); intent.putExtra(MediaStore.EXTRA_OUTPUT, photoURI); startActivityForResult(intent, REQUEST_CAMERA); } catch (IOException e) { e.printStackTrace(); } } }); layoutGallery.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { Intent intent = new Intent(Intent.ACTION_PICK, MediaStore.Images.Media.EXTERNAL_CONTENT_URI); intent.setType("image/*"); startActivityForResult(Intent.createChooser(intent, "Select File"), SELECT_FILE); } }); buttonSubmit.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { progressDialog = new ProgressDialog(DashBoardEditActivity.this); progressDialog.setMessage(getResources().getString(R.string.please_wait)); progressDialog.setCancelable(false); progressDialog.show(); UpdateUserInfo updateUserInfo = new UpdateUserInfo(getApplicationContext()); updateUserInfo.signUpListener = DashBoardEditActivity.this; //viewEnable(false); if (userType == AppGlobal.CAR_OWNER) { boolean hasError = false; boolean hasPhoneNoError = false; if (etFirstName.getText().length() == 0) { etFirstName.setError(getResources().getString(R.string.enter_first_name)); hasError = true; } if (etLastName.getText().length() == 0) { etLastName.setError(getResources().getString(R.string.enter_last_name)); hasError = true; } if (etPhoneNumber.getText().length() == 0) { etPhoneNumber.setError(getResources().getString(R.string.enter_phone_no)); hasError = true; hasPhoneNoError = true; } if (!hasPhoneNoError && etPhoneNumber.getText().length() != 11) { etPhoneNumber.setError(getResources().getString(R.string.enter_valid_phone_no)); hasError = true; } if (etEmail.getText().length() != 0 && !Patterns.EMAIL_ADDRESS.matcher(etEmail.getText().toString()).matches()) { etEmail.setError(getResources().getString(R.string.enter_valid_email)); hasError = true; } if (etAddress.getText().length() == 0) { etAddress.setError(getResources().getString(R.string.enter_address)); hasError = true; } if (hasError) { if (progressDialog.isShowing()) progressDialog.dismiss(); return; } HashMap<String, String> params = new HashMap<>(); params.put("authentication", AppGlobal.authentication); params.put("api_token", sharedPreferences.getString("api_token", "")); params.put("phone", etPhoneNumber.getText().toString()); params.put("firstname", etFirstName.getText().toString()); if (!etMiddleName.getText().toString().equals("")) { params.put("middlename", etMiddleName.getText().toString()); } params.put("lastname", etLastName.getText().toString()); params.put("district_id", "1"); params.put("area_id", String.valueOf(areaId)); params.put("address", etAddress.getText().toString()); if (!etEmail.getText().toString().equals("")) { params.put("email", etEmail.getText().toString()); } if (!image.equals("")) { params.put("image", image); } updateUserInfo.parseData(params, "updateCarOwnerInfo"); } else if (userType == AppGlobal.SUPPLIER) { boolean hasError = false; boolean hasPhoneNoError = false; if (etFirstName.getText().length() == 0) { etFirstName.setError(getResources().getString(R.string.enter_first_name)); hasError = true; } if (etLastName.getText().length() == 0) { etLastName.setError(getResources().getString(R.string.enter_last_name)); hasError = true; } if (etPhoneNumber.getText().length() == 0) { etPhoneNumber.setError(getResources().getString(R.string.enter_phone_no)); hasError = true; hasPhoneNoError = true; } if (!hasPhoneNoError && etPhoneNumber.getText().length() != 11) { etPhoneNumber.setError(getResources().getString(R.string.enter_valid_phone_no)); hasError = true; } if (etEmail.getText().length() != 0 && !Patterns.EMAIL_ADDRESS.matcher(etEmail.getText().toString()).matches()) { etEmail.setError(getResources().getString(R.string.enter_valid_email)); hasError = true; } if (etShopName.getText().length() == 0) { etShopName.setError(getResources().getString(R.string.enter_shop_name)); hasError = true; } if (etAddress.getText().length() == 0) { etAddress.setError(getResources().getString(R.string.enter_address)); hasError = true; } if (hasError) { if (progressDialog.isShowing()) progressDialog.dismiss(); return; } HashMap<String, String> params = new HashMap<>(); params.put("authentication", AppGlobal.authentication); params.put("api_token", sharedPreferences.getString("api_token", "")); params.put("phone", etPhoneNumber.getText().toString()); params.put("firstname", etFirstName.getText().toString()); if (!etMiddleName.getText().toString().equals("")) { params.put("middlename", etMiddleName.getText().toString()); } params.put("lastname", etLastName.getText().toString()); params.put("district_id", "1"); params.put("area_id", String.valueOf(areaId)); if (!etEmail.getText().toString().equals("")) { params.put("email", etEmail.getText().toString()); } if (!image.equals("")) { params.put("image", image); } params.put("shopname", etShopName.getText().toString()); params.put("address", etAddress.getText().toString()); for (int i = 0; i < selectedProductIdList.size(); i++) { params.put("products[" + i + "]", selectedProductIdList.get(i)); } for (int i = 0; i < chosenBrandIdList.size(); i++) { params.put("brands[" + i + "]", chosenBrandIdList.get(i)); } updateUserInfo.parseData(params, "updateSupplierInfo"); } else if (userType == AppGlobal.DRIVER) { boolean hasError = false; boolean hasPhoneNoError = false; boolean hasDrivingLicenseNoError = false; boolean hasNidNoError = false; if (etFirstName.getText().length() == 0) { etFirstName.setError(getResources().getString(R.string.enter_first_name)); hasError = true; } if (etLastName.getText().length() == 0) { etLastName.setError(getResources().getString(R.string.enter_last_name)); hasError = true; } if (etPhoneNumber.getText().length() == 0) { etPhoneNumber.setError(getResources().getString(R.string.enter_phone_no)); hasError = true; hasPhoneNoError = true; } if (!hasPhoneNoError && etPhoneNumber.getText().length() != 11) { etPhoneNumber.setError(getResources().getString(R.string.enter_valid_phone_no)); hasError = true; } if (etEmail.getText().length() != 0 && !Patterns.EMAIL_ADDRESS.matcher(etEmail.getText().toString()).matches()) { etEmail.setError(getResources().getString(R.string.enter_valid_email)); hasError = true; } if (etDrivingLicense.getText().length() == 0) { etDrivingLicense.setError(getResources().getString(R.string.enter_driving_licence)); hasError = true; hasDrivingLicenseNoError = true; } if (!hasDrivingLicenseNoError && etDrivingLicense.getText().length() != 15) { etDrivingLicense.setError(getResources().getString(R.string.enter_valid_driving_licence)); hasError = true; } if (etNid.getText().length() == 0) { etNid.setError(getResources().getString(R.string.enter_nid_no)); hasError = true; hasNidNoError = true; } if (!hasNidNoError && etNid.getText().length() != 17) { etNid.setError(getResources().getString(R.string.enter_valid_nid)); hasError = true; } if (etExperience.getText().length() == 0) { etExperience.setError(getResources().getString(R.string.enter_year_of_experience)); hasError = true; } if (hasError) { if (progressDialog.isShowing()) progressDialog.dismiss(); return; } HashMap<String, String> params = new HashMap<>(); params.put("authentication", AppGlobal.authentication); params.put("api_token", sharedPreferences.getString("api_token", "")); params.put("phone", etPhoneNumber.getText().toString()); params.put("firstname", etFirstName.getText().toString()); if (!etMiddleName.getText().toString().equals("")) { params.put("middlename", etMiddleName.getText().toString()); } params.put("lastname", etLastName.getText().toString()); params.put("drivinglicence", etDrivingLicense.getText().toString()); params.put("nid", etNid.getText().toString()); params.put("yearofexperience", etExperience.getText().toString()); if (!etEmail.getText().toString().equals("")) { params.put("email", etEmail.getText().toString()); } if (!image.equals("")) { params.put("image", image); } updateUserInfo.parseData(params, "updateDriverInfo"); } else if (userType == AppGlobal.SHOP_WORKER) { boolean hasError = false; boolean hasPhoneNoError = false; if (etFirstName.getText().length() == 0) { etFirstName.setError(getResources().getString(R.string.enter_first_name)); hasError = true; } if (etLastName.getText().length() == 0) { etLastName.setError(getResources().getString(R.string.enter_last_name)); hasError = true; } if (etPhoneNumber.getText().length() == 0) { etPhoneNumber.setError(getResources().getString(R.string.enter_phone_no)); hasError = true; hasPhoneNoError = true; } if (!hasPhoneNoError && etPhoneNumber.getText().length() != 11) { etPhoneNumber.setError(getResources().getString(R.string.enter_valid_phone_no)); hasError = true; } if (etEmail.getText().length() != 0 && !Patterns.EMAIL_ADDRESS.matcher(etEmail.getText().toString()).matches()) { etEmail.setError(getResources().getString(R.string.enter_valid_email)); hasError = true; } if (etNid.getText().length() == 0) { etNid.setError(getResources().getString(R.string.enter_nid_no)); hasError = true; } if (etShopName.getText().length() == 0) { etShopName.setError(getResources().getString(R.string.enter_shop_name)); hasError = true; } if (hasError) { if (progressDialog.isShowing()) progressDialog.dismiss(); return; } HashMap<String, String> params = new HashMap<>(); params.put("authentication", AppGlobal.authentication); params.put("api_token", sharedPreferences.getString("api_token", "")); params.put("phone", etPhoneNumber.getText().toString()); params.put("firstname", etFirstName.getText().toString()); if (!etMiddleName.getText().toString().equals("")) { params.put("middlename", etMiddleName.getText().toString()); } params.put("lastname", etLastName.getText().toString()); params.put("nid", etNid.getText().toString()); params.put("shopname", etShopName.getText().toString()); if (!etEmail.getText().toString().equals("")) { params.put("email", etEmail.getText().toString()); } if (!image.equals("")) { params.put("image", image); } updateUserInfo.parseData(params, "updateWorkerInfo"); } } }); }
From source file:com.android.cts.verifier.managedprovisioning.ByodHelperActivity.java
public static Intent getCaptureImageIntent() { return new Intent(MediaStore.ACTION_IMAGE_CAPTURE); }
From source file:eu.nubomedia.nubomedia_kurento_health_communicator_android.kc_and_communicator.util.FileUtils.java
public static void takePicture(Context ctx, Uri mFileCaptureUri) { if (!isIntentAvailable(ctx, MediaStore.ACTION_IMAGE_CAPTURE)) { log.warn("Cannot take picture (Intent is not available)"); return;//from w w w .j a v a2s. c o m } Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); intent.putExtra(MediaStore.EXTRA_OUTPUT, mFileCaptureUri); intent.putExtra("return-data", true); try { ((Activity) ctx).startActivityForResult(intent, AppUtils.ACTION_TAKE_PICTURE); } catch (ActivityNotFoundException e) { log.warn("Cannot take picture", e); } }
From source file:cn.zsmy.akm.doctor.profile.fragment.UploadPhotoFragment.java
/** * poppupwindow?position?button// w w w. j a va 2s.c o m * * @param0 ? * @param1 ****/ @Override public void onItemClick(int position) { switch (position) { case 0: PHOTO_CREAME = CREAME; Intent openCameraIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); File file = new File(Environment.getExternalStorageDirectory().getAbsolutePath() + "/" + String.valueOf(System.currentTimeMillis()) + ".jpg"); tempUri = Uri.fromFile(file); openCameraIntent.putExtra(MediaStore.EXTRA_OUTPUT, tempUri); startActivityForResult(openCameraIntent, PIC); break; case 1: PHOTO_CREAME = PHOTO; Intent i = new Intent(Intent.ACTION_PICK, android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI); startActivityForResult(i, PIC); break; default: break; } WHETHER_FROM_ACTIVITY_BACK = true; }
From source file:com.almalence.opencam.ApplicationScreen.java
public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); sEvPref = getResources().getString(R.string.Preference_EvCompensationValue); sSceneModePref = getResources().getString(R.string.Preference_SceneModeValue); sWBModePref = getResources().getString(R.string.Preference_WBModeValue); sColorTemperaturePref = getResources().getString(R.string.Preference_ColorTemperatureValue); sFrontFocusModePref = getResources().getString(R.string.Preference_FrontFocusModeValue); sFrontFocusModeVideoPref = getResources().getString(R.string.Preference_FrontFocusModeVideoValue); sRearFocusModePref = getResources().getString(R.string.Preference_RearFocusModeValue); sRearFocusModeVideoPref = getResources().getString(R.string.Preference_RearFocusModeVideoValue); sFrontColorEffectPref = getResources().getString(R.string.Preference_FrontColorEffectValue); sRearColorEffectPref = getResources().getString(R.string.Preference_RearColorEffectValue); sFlashModePref = getResources().getString(R.string.Preference_FlashModeValue); sISOPref = getResources().getString(R.string.Preference_ISOValue); sMeteringModePref = getResources().getString(R.string.Preference_MeteringModeValue); sExposureTimePref = getResources().getString(R.string.Preference_ExposureTimeValue); sExposureTimeModePref = getResources().getString(R.string.Preference_ExposureTimeModeValue); sRealExposureTimeOnPreviewPref = getResources() .getString(R.string.Preference_RealExposureTimeOnPreviewValue); sFocusDistancePref = getResources().getString(R.string.Preference_FocusDistanceValue); sFocusDistanceModePref = getResources().getString(R.string.Preference_FocusDistanceModeValue); sCameraModePref = getResources().getString(R.string.Preference_CameraModeValue); sUseFrontCameraPref = getResources().getString(R.string.Preference_UseFrontCameraValue); sImageSizeRearPref = getResources().getString(R.string.Preference_ImageSizeRearValue); sImageSizeFrontPref = getResources().getString(R.string.Preference_ImageSizeFrontValue); sImageSizeSonyRemotePref = getResources().getString(R.string.Preference_ImageSizeSonyRemoteValue); sImageSizeMultishotBackPref = getResources() .getString(R.string.Preference_ImageSizePrefSmartMultishotBackValue); sImageSizeMultishotFrontPref = getResources() .getString(R.string.Preference_ImageSizePrefSmartMultishotFrontValue); sImageSizeMultishotSonyRemotePref = getResources() .getString(R.string.Preference_ImageSizePrefSmartMultishotSonyRemoteValue); sImageSizePanoramaBackPref = getResources().getString(R.string.Preference_ImageSizePrefPanoramaBackValue); sImageSizePanoramaFrontPref = getResources().getString(R.string.Preference_ImageSizePrefPanoramaFrontValue); sImageSizeVideoBackPref = getResources().getString(R.string.Preference_ImageSizePrefVideoBackValue); sImageSizeVideoFrontPref = getResources().getString(R.string.Preference_ImageSizePrefVideoFrontValue); sCaptureRAWPref = getResources().getString(R.string.Preference_CaptureRAWValue); sJPEGQualityPref = getResources().getString(R.string.Preference_JPEGQualityCommonValue); sAntibandingPref = getResources().getString(R.string.Preference_AntibandingValue); sExportNamePref = getResources().getString(R.string.Preference_ExportNameValue); sExportNameSeparatorPref = getResources().getString(R.string.Preference_ExportNameSeparatorValue); sExportNamePrefixPref = getResources().getString(R.string.Preference_SavePathPrefixValue); sExportNamePostfixPref = getResources().getString(R.string.Preference_SavePathPostfixValue); sSavePathPref = getResources().getString(R.string.Preference_SavePathValue); sSaveToPref = getResources().getString(R.string.Preference_SaveToValue); sSortByDataPref = getResources().getString(R.string.Preference_SortByDataValue); sEnableExifOrientationTagPref = getResources().getString(R.string.Preference_EnableExifTagOrientationValue); sAdditionalRotationPref = getResources().getString(R.string.Preference_AdditionalRotationValue); sUseGeotaggingPref = getResources().getString(R.string.Preference_UseGeotaggingValue); sTimestampDate = getResources().getString(R.string.Preference_TimestampDateValue); sTimestampAbbreviation = getResources().getString(R.string.Preference_TimestampAbbreviationValue); sTimestampTime = getResources().getString(R.string.Preference_TimestampTimeValue); sTimestampGeo = getResources().getString(R.string.Preference_TimestampGeoValue); sTimestampSeparator = getResources().getString(R.string.Preference_TimestampSeparatorValue); sTimestampCustomText = getResources().getString(R.string.Preference_TimestampCustomTextValue); sTimestampColor = getResources().getString(R.string.Preference_TimestampColorValue); sTimestampFontSize = getResources().getString(R.string.Preference_TimestampFontSizeValue); sAELockPref = getResources().getString(R.string.Preference_AELockValue); sAWBLockPref = getResources().getString(R.string.Preference_AWBLockValue); sExpoPreviewModePref = getResources().getString(R.string.Preference_ExpoBracketingPreviewModePref); sDefaultModeName = getResources().getString(R.string.Preference_DefaultModeName); mainContext = this.getBaseContext(); messageHandler = new Handler(this); instance = this; surfaceCreated = false;/* w w w. ja va 2s . co m*/ requestWindowFeature(Window.FEATURE_NO_TITLE); // ensure landscape orientation setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); // set to fullscreen getWindow().addFlags( WindowManager.LayoutParams.FLAG_FULLSCREEN | WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD | WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED); // set some common view here // setContentView(R.layout.opencamera_main_layout); createPluginManager(); duringOnCreate(); try { cameraController = CameraController.getInstance(); } catch (VerifyError exp) { Log.e("ApplicationScreen", exp.getMessage()); } CameraController.onCreate(ApplicationScreen.instance, ApplicationScreen.instance, pluginManager, ApplicationScreen.instance.messageHandler); SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(ApplicationScreen.getMainContext()); keepScreenOn = prefs.getBoolean("keepScreenOn", false); // set preview, on click listener and surface buffers // findViewById(R.id.SurfaceView02).setVisibility(View.GONE); // preview = (SurfaceView) this.findViewById(R.id.SurfaceView01); // preview.setOnClickListener(this); // preview.setOnTouchListener(this); // preview.setKeepScreenOn(true); // // surfaceHolder = preview.getHolder(); // surfaceHolder.addCallback(this); orientListener = new OrientationEventListener(this) { @Override public void onOrientationChanged(int orientation) { // figure landscape or portrait if (ApplicationScreen.instance.landscapeIsNormal) { orientation += 90; } if ((orientation < 45) || (orientation > 315 && orientation < 405) || ((orientation > 135) && (orientation < 225))) { if (ApplicationScreen.wantLandscapePhoto) { ApplicationScreen.wantLandscapePhoto = false; } } else { if (!ApplicationScreen.wantLandscapePhoto) { ApplicationScreen.wantLandscapePhoto = true; } } // orient properly for video if ((orientation > 135) && (orientation < 225)) orientationMain = 270; else if ((orientation < 45) || (orientation > 315)) orientationMain = 90; else if ((orientation < 325) && (orientation > 225)) orientationMain = 0; else if ((orientation < 135) && (orientation > 45)) orientationMain = 180; if (orientationMain != orientationMainPrevious) { orientationMainPrevious = orientationMain; } } }; // prevent power drain screenTimer = new CountDownTimer(180000, 180000) { public void onTick(long millisUntilFinished) { // Not used } public void onFinish() { boolean isVideoRecording = PreferenceManager .getDefaultSharedPreferences(ApplicationScreen.getMainContext()) .getBoolean("videorecording", false); if (isVideoRecording || keepScreenOn) { // restart timer screenTimer.start(); isScreenTimerRunning = true; if (preview != null) { preview.setKeepScreenOn(true); } return; } if (preview != null) { preview.setKeepScreenOn(keepScreenOn); } isScreenTimerRunning = false; } }; screenTimer.start(); isScreenTimerRunning = true; if (this.getIntent().getAction() != null) { if (this.getIntent().getAction().equals(MediaStore.ACTION_IMAGE_CAPTURE)) { try { forceFilenameUri = this.getIntent().getExtras().getParcelable(MediaStore.EXTRA_OUTPUT); ApplicationScreen.setForceFilename(new File(((Uri) forceFilenameUri).getPath())); if (ApplicationScreen.getForceFilename().getAbsolutePath().equals("/scrapSpace")) { ApplicationScreen.setForceFilename( new File(Environment.getExternalStorageDirectory().getAbsolutePath() + "/mms/scrapSpace/.temp.jpg")); new File(ApplicationScreen.getForceFilename().getParent()).mkdirs(); } } catch (Exception e) { ApplicationScreen.setForceFilename(null); } } else { ApplicationScreen.setForceFilename(null); } } else { ApplicationScreen.setForceFilename(null); } afterOnCreate(); }
From source file:org.openmrs.mobile.activities.addeditpatient.AddEditPatientFragment.java
@NeedsPermission({ Manifest.permission.CAMERA, Manifest.permission.WRITE_EXTERNAL_STORAGE }) public void capturePhoto() { Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); if (takePictureIntent.resolveActivity(getContext().getPackageManager()) != null) { File dir = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DCIM); output = new File(dir, getUniqueImageFileName()); takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(output)); startActivityForResult(takePictureIntent, IMAGE_REQUEST); }//from w w w . j a va 2 s .c o m }