List of usage examples for android.content Intent resolveActivity
public ComponentName resolveActivity(@NonNull PackageManager pm)
From source file:uk.ac.horizon.artcodes.activity.ExperienceEditActivity.java
private void selectImage(int request_id) { Intent intent = new Intent(Intent.ACTION_GET_CONTENT); intent.setType("image/*"); if (intent.resolveActivity(getPackageManager()) != null) { startActivityForResult(intent, request_id); }/*from ww w. j av a2s. c om*/ }
From source file:br.com.brolam.cloudvision.ui.helpers.ImagesHelper.java
/** * Realizar uma requisio de uma foto na camera fotogrfica nativa do Android para uma imagem * de background Note Vision./*from w w w . j av a 2s .co m*/ * @param noteVisionKey informar uma chave vlida. * @throws IOException */ public void takeNoteVisionBackground(String noteVisionKey) throws IOException { Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); if (takePictureIntent.resolveActivity(activity.getPackageManager()) != null) { //Informar o arquivo temporrio onde a imagem ser gravada. takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, getImageUriFileProvider(noteVisionKey)); //Informar a chave do Note Vision que ser recuperado no mtodo {@see saveNoteVisionBackground} requestImageNoteVisionKey = noteVisionKey; activity.startActivityForResult(takePictureIntent, REQUEST_IMAGE_CAPTURE); } }
From source file:com.ultramegasoft.flavordex2.fragment.AbsPhotosFragment.java
/** * Launch an image selection Intent.//from w w w.j a va 2 s .c om */ final void addPhotoFromGallery() { final Context context = getContext(); final Fragment parent = getParentFragment(); if (context == null || parent == null) { return; } final Intent intent = PhotoUtils.getSelectPhotoIntent(); if (intent.resolveActivity(context.getPackageManager()) != null) { parent.startActivityForResult(intent, REQUEST_SELECT_IMAGE); } }
From source file:mysteryinc.eagleeye.LiveLocatorFragment.java
/** * Start the camera by dispatching a camera intent. Returns a string location to the photo. *///from w w w. j a va2 s .c o m private String takePicture() { // Check if there is a camera. if (deviceMissingCamera()) { MainActivity.toast("This device does not have a camera."); return ""; } // Camera exists? Then proceed... Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); // Ensure that there's a camera activity to handle the intent Activity activity = getActivity(); File photoFile = null; if (takePictureIntent.resolveActivity(activity.getPackageManager()) != null) { // Create the File where the photo should go. // If you don't do this, you may get a crash in some devices. try { photoFile = createImageFile(); } catch (IOException ex) { // Error occurred while creating the File ex.printStackTrace(); MainActivity.toast("There was a problem saving the photo..."); } // Continue only if the File was successfully created if (photoFile != null) { Uri fileUri = Uri.fromFile(photoFile); // activity.setCapturedImageURI(fileUri); // activity.setCurrentPhotoPath(fileUri.getPath()); takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, fileUri); // activity.getCapturedImageURI()); startActivityForResult(takePictureIntent, REQUEST_TAKE_PHOTO); } } return photoFile.getAbsolutePath(); }
From source file:com.xamoom.android.xamoomcontentblocks.XamoomMapFragment.java
private void showActiveMarker(final Marker marker) { mActiveMarker = marker;//w w w. j av a2 s .c om mActiveMarker.showInfoWindow(); zoomToMarker(mActiveMarker, false); mBottomSheetBehavior.setState(BottomSheetBehavior.STATE_COLLAPSED); mFloatingActionButton.show(); final Spot spot = mMarkerSpotMap.get(marker); mSpotTitleTextView.setText(spot.getName()); mSpotExcerptTextView.setText(spot.getDescription()); Glide.with(this).load(spot.getPublicImageUrl()).into(mSpotImageView); if (spot.getContent() != null && spot.getContent().getId() != null) { mSpotContentButton.setVisibility(View.VISIBLE); final String contentId = spot.getContent().getId(); mSpotContentButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { mListener.clickedSpotMapContentLink(contentId); } }); } else { mSpotContentButton.setVisibility(View.GONE); } mFloatingActionButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { double lat = marker.getPosition().latitude; double lon = marker.getPosition().longitude; String query = lat + "," + lon + "(" + spot.getName() + ")"; Uri gmmIntentUri = Uri.parse("geo:" + lat + "+," + lon + "?q=" + query); Intent mapIntent = new Intent(Intent.ACTION_VIEW, gmmIntentUri); mapIntent.setPackage("com.google.android.apps.maps"); if (mapIntent.resolveActivity(getContext().getPackageManager()) != null) { startActivity(mapIntent); } } }); }
From source file:com.luke.lukef.lukeapp.fragments.NewSubmissionFragment.java
/** * Activates camera intent//from w w w . j a va2 s. c om */ private void dispatchTakePictureIntent() { Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); if (takePictureIntent.resolveActivity(getMainActivity().getPackageManager()) != null) { // Create the File where the photo should go if (photoFile != null) { this.photoPath = photoFile.getAbsolutePath(); // Continue only if the File was successfully created Uri photoURI = FileProvider.getUriForFile(getMainActivity(), "com.luke.lukef.lukeapp", photoFile); takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, photoURI); startActivityForResult(takePictureIntent, REQUEST_IMAGE_CAPTURE); } else { createImageFile(); dispatchTakePictureIntent(); } } }
From source file:com.example.android.implicitintents.MainActivity.java
/** * This method will fire off an implicit Intent to view a location on a map. * * When constructing implicit Intents, you can use either the setData method or specify the * URI as the second parameter of the Intent's constructor, * as I do in {@link #openWebPage(String)} * * @param geoLocation The Uri representing the location that will be opened in the map *//*from w w w. ja va 2s . co m*/ private void showMap(Uri geoLocation) { /* * Again, we create an Intent with the action, ACTION_VIEW because we want to VIEW the * contents of this Uri. */ Intent intent = new Intent(Intent.ACTION_VIEW); /* * Using setData to set the Uri of this Intent has the exact same affect as passing it in * the Intent's constructor. This is simply an alternate way of doing this. */ intent.setData(geoLocation); if (intent.resolveActivity(getPackageManager()) != null) { startActivity(intent); } }
From source file:com.workingagenda.devinettes.AboutActivity.java
@Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case android.R.id.home: NavUtils.navigateUpFromSameTask(this); return true; case R.id.action_source: Intent i = new Intent(Intent.ACTION_VIEW); i.setData(Uri.parse("https://github.com/fenimore/devinettes-android")); startActivity(i);//from w w w .j av a 2s.c om return true; case R.id.action_mail: String[] addresses = new String[1]; addresses[0] = "exorable.ludos@gmail.com"; Intent intent = new Intent(Intent.ACTION_SEND); intent.setType("*/*"); intent.putExtra(Intent.EXTRA_EMAIL, addresses); intent.putExtra(Intent.EXTRA_SUBJECT, "Riddle Answer Please :)"); intent.putExtra(Intent.EXTRA_TEXT, "Please include the Riddle you're interested" + "in, and the donation amount."); if (intent.resolveActivity(getPackageManager()) != null) { startActivity(intent); } startActivity(intent); return true; } return super.onOptionsItemSelected(item); }
From source file:mx.klozz.xperience.tweaker.fragments.BatteryInfo.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup root, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.battery_info, root, false); mBattery_Percent = (TextView) view.findViewById(R.id.battery_percent); mBattery_volt = (TextView) view.findViewById(R.id.battery_volt); mBattery_Status = (TextView) view.findViewById(R.id.battery_status); mBatteryIcon = (ImageView) view.findViewById(R.id.battery_icon); //Checamos si existe algo relacionado con la direccion de voltajes if (new File(BAT_VOLT_PATH).exists()) { int volt = Integer.parseInt(Helpers.LeerUnaLinea(BAT_VOLT_PATH));//vemos si existe el directorio if (volt > 5000) volt = (int) Math.round(volt / 1000.0);//Convertimos a microvolts mBattery_volt.setText(volt + " mV");//Hacemos visible los datos mBatteryIcon.setVisibility(ImageView.GONE); mBattery_volt.setVisibility(TextView.VISIBLE); mBattery_volt.setOnClickListener(new View.OnClickListener() { @Override/* ww w. java 2s .c o m*/ public void onClick(View view) { Intent powerUsageIntent = new Intent(Intent.ACTION_POWER_USAGE_SUMMARY); if (powerUsageIntent.resolveActivity(context.getPackageManager()) != null) startActivity(powerUsageIntent); } }); mBattery_volt.setOnLongClickListener(new View.OnLongClickListener() { @Override public boolean onLongClick(View view) { mBatteryIcon.setVisibility(ImageView.VISIBLE); mBattery_volt.setVisibility(TextView.GONE); return true; } }); } else { mBatteryIcon.setVisibility(ImageView.VISIBLE); mBattery_volt.setVisibility(TextView.GONE); mBatteryIcon.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { try { Intent powerUsageIntent = new Intent(Intent.ACTION_POWER_USAGE_SUMMARY); startActivity(powerUsageIntent); } catch (Exception e) { } } }); } mFastChargePath = Helpers.fastcharge_path(); if (mFastChargePath != null) { no_settings = false; mFastChargeOnBoot = (Switch) view.findViewById(R.id.fastcharge_sob); mFastChargeOnBoot.setChecked( mPreferences.getBoolean(PREF_FASTCHARGE, Helpers.LeerUnaLinea(mFastChargePath).equals("1"))); mFastChargeOnBoot.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton v, boolean checked) { mPreferences.edit().putBoolean(PREF_FASTCHARGE, checked).apply(); final NotificationManager NM = (NotificationManager) context .getSystemService(Context.NOTIFICATION_SERVICE); if (checked) { new CMDProcessor().su.runWaitFor("busybox exho 1 > " + mFastChargePath); Notification N = new Notification.Builder(context) .setContentTitle(context.getText(R.string.app_name)) .setContentText(context.getText(R.string.fast_charge_notification_title)) .setTicker(context.getText(R.string.fast_charge_notification_title)) .setSmallIcon(R.drawable.ic_fastcharge).setWhen(System.currentTimeMillis()) .getNotification(); NM.notify(1337, N); } else { new CMDProcessor().su.runWaitFor("busybox echo 0 > " + mFastChargePath); NM.cancel(1337); } } }); } else { LinearLayout mPart = (LinearLayout) view.findViewById(R.id.fastcharge_layout); mPart.setVisibility(LinearLayout.GONE); } if (no_settings) { LinearLayout NS = (LinearLayout) view.findViewById(R.id.no_settings); NS.setVisibility(LinearLayout.VISIBLE); } return view; }
From source file:camera.AnotherCamera.java
/** * Start the camera by dispatching a camera intent. *//*from w w w . j av a2 s .co m*/ protected void dispatchTakePictureIntent() { // Check if there is a camera. Context context = getActivity(); PackageManager packageManager = context.getPackageManager(); if (packageManager.hasSystemFeature(PackageManager.FEATURE_CAMERA) == false) { Toast.makeText(getActivity(), "This device does not have a camera.", Toast.LENGTH_SHORT).show(); return; } // Camera exists? Then proceed... Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); // Ensure that there's a camera activity to handle the intent CameraActivity activity = (CameraActivity) getActivity(); if (takePictureIntent.resolveActivity(activity.getPackageManager()) != null) { // Create the File where the photo should go. // If you don't do this, you may get a crash in some devices. File photoFile = null; try { photoFile = createImageFile(); } catch (IOException ex) { // Error occurred while creating the File Toast toast = Toast.makeText(activity, "There was a problem saving the photo...", Toast.LENGTH_SHORT); toast.show(); } // Continue only if the File was successfully created if (photoFile != null) { Uri fileUri = Uri.fromFile(photoFile); activity.setCapturedImageURI(fileUri); activity.setCurrentPhotoPath(fileUri.getPath()); takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, activity.getCapturedImageURI()); startActivityForResult(takePictureIntent, REQUEST_TAKE_PHOTO); } } }