List of usage examples for android.content Intent resolveActivity
public ComponentName resolveActivity(@NonNull PackageManager pm)
From source file:com.example.mego.adas.main.AboutFragment.java
/** * open a web view with giver Uri/*from w ww .jav a 2 s. c om*/ */ private void openFacebookIntent(String Uri) { Intent openFacebookIntent = new Intent(Intent.ACTION_VIEW); openFacebookIntent.setData(android.net.Uri.parse(Uri)); //check for the web intent if (openFacebookIntent.resolveActivity(getActivity().getPackageManager()) != null) { startActivity(openFacebookIntent); } }
From source file:com.microsoft.projectoxford.visionsample.helper.SelectImageActivity.java
public void selectImageInAlbum(View view) { Intent intent = new Intent(Intent.ACTION_GET_CONTENT); intent.setType("mFilePhotoTaken/*"); if (intent.resolveActivity(getPackageManager()) != null) { startActivityForResult(intent, REQUEST_SELECT_IMAGE_IN_ALBUM); }/*w ww . jav a 2 s .co m*/ }
From source file:org.berlin_vegan.bvapp.activities.LocationDetailActivity.java
private void navigationButtonClicked() { // tested with oeffi, google maps,citymapper and osmand final String uriString = "geo:" + mGastroLocation.getLatCoord() + "," + mGastroLocation.getLongCoord() + "?q=" + mGastroLocation.getStreet() + ", " + mGastroLocation.getCityCode() + ", " + mGastroLocation.getCity(); Uri geoIntentUri = Uri.parse(uriString); Intent geoIntent = new Intent(Intent.ACTION_VIEW, geoIntentUri); if (geoIntent.resolveActivity(getPackageManager()) != null) { startActivity(geoIntent);//from ww w . j a va 2s. c om } else { UiUtils.showMaterialDialog(this, getString(R.string.error), getString(R.string.gastro_details_no_navigation_found)); } }
From source file:com.jefftharris.passwdsafe.lib.DynamicPermissionMgr.java
@Override public void onClick(View v) { int id = v.getId(); if (id == itsReloadBtn.getId()) { checkPerms();/*from www . ja v a 2 s. co m*/ } else if (id == itsAppSettingsBtn.getId()) { Intent intent = new Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS); intent.setData(Uri.parse("package:" + itsPackageName)); if (intent.resolveActivity(itsActivity.getPackageManager()) != null) { itsActivity.startActivityForResult(intent, itsAppSettingsRequestCode); } } }
From source file:org.alfresco.mobile.android.application.capture.AudioCapture.java
@Override public boolean captureData() { if (hasDevice()) { try {//from w w w . j a va 2 s.c o m Intent intent = new Intent(MediaStore.Audio.Media.RECORD_SOUND_ACTION); if (intent.resolveActivity(context.getPackageManager()) == null) { AlfrescoNotificationManager.getInstance(context).showAlertCrouton(parentActivity, context.getString(R.string.feature_disable)); return false; } else { parentActivity.startActivityForResult(intent, getRequestCode()); } } catch (Exception e) { AlfrescoNotificationManager.getInstance(context).showAlertCrouton(parentActivity, context.getString(R.string.no_voice_recorder)); Log.d(TAG, Log.getStackTraceString(e)); return false; } return true; } else { return false; } }
From source file:com.nexus.nsnik.randomno.view.fragments.dailogFragments.AboutDialogFragment.java
private void openUrl(String url) { Intent urlIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(url)); if (getActivity() != null && urlIntent.resolveActivity(getActivity().getPackageManager()) != null) startActivity(urlIntent);// w w w . ja v a 2s. c o m }
From source file:de.grobox.blitzmail.MainActivity.java
private void addSendNowPref(final Context c) { JSONObject mails = MailStorage.getMails(this); if (mails != null && mails.length() > 0) { PreferenceCategory targetCategory = (PreferenceCategory) findPreference("pref_sending"); Preference pref = new Preference(this); pref.setKey("pref_send_now"); pref.setTitle(R.string.pref_send_now); pref.setSummary(/*from ww w . j a v a 2 s . com*/ String.format(getResources().getString(R.string.pref_send_now_summary), mails.length())); pref.setOnPreferenceClickListener(new OnPreferenceClickListener() { public boolean onPreferenceClick(Preference preference) { if (BuildConfig.PRO) sendNow(); else { AlertDialog.Builder builder = new AlertDialog.Builder(c); builder.setTitle(c.getString(R.string.app_name)); builder.setMessage(c.getString(R.string.error_lite_version)); builder.setIcon(android.R.drawable.ic_dialog_info); // Add the buttons builder.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { Uri uri = Uri.parse( "https://play.google.com/store/apps/details?id=de.grobox.blitzmail.pro"); Intent intent = new Intent(Intent.ACTION_VIEW, uri); if (intent.resolveActivity(c.getPackageManager()) != null) { c.startActivity(intent); } dialog.dismiss(); } }); builder.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.dismiss(); } }); // Create and show the AlertDialog AlertDialog dialog = builder.create(); dialog.setCanceledOnTouchOutside(false); dialog.show(); } return true; } }); targetCategory.addPreference(pref); } }
From source file:com.orange.ocara.ui.activity.EditCommentAudioActivity.java
private void launchRecorder() { final Intent intent = new Intent(MediaStore.Audio.Media.RECORD_SOUND_ACTION); if (intent.resolveActivity(getPackageManager()) != null) { startActivityForResult(intent, RECORD_AUDIO_REQUEST_CODE); } else {//from w ww . j a v a 2 s . c o m startPlayingRecordingButton.setVisibility(View.VISIBLE); } }
From source file:com.monmonja.library.social.SocialNetworkDialogFragment.java
/** * Start the camera by dispatching a camera intent. */ protected void dispatchTakePictureIntent() { PackageManager packageManager = getActivity().getPackageManager(); if (!packageManager.hasSystemFeature(PackageManager.FEATURE_CAMERA)) { Toast.makeText(getActivity(), "This device does not have a camera.", Toast.LENGTH_SHORT).show(); return;//from w ww.j av a 2s .com } Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); if (takePictureIntent.resolveActivity(getActivity().getPackageManager()) != null) { try { File tempFile = getTempCaptureImgPath(); mTempTakePicturePath = tempFile.getAbsolutePath(); takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(tempFile)); startActivityForResult(takePictureIntent, REQUEST_IMAGE_CAPTURE); } catch (IOException ex) { } } }
From source file:com.schedjoules.eventdiscovery.framework.actions.ShareActionExecutable.java
@Override public void execute(@NonNull Activity activity) { new InsightsTask(activity).execute(new ActionInteraction(mLink, mEvent)); String eventText = eventText(activity); Intent sendIntent = ShareCompat.IntentBuilder.from(activity).setText(eventText).setType("text/plain") .setChooserTitle(R.string.schedjoules_action_share_chooser_title).createChooserIntent(); if (sendIntent.resolveActivity(activity.getPackageManager()) != null) { activity.startActivity(sendIntent); } else {/*from www . j a v a2s. c om*/ Toast.makeText(activity, R.string.schedjoules_action_cannot_handle_message, Toast.LENGTH_LONG).show(); } }