List of usage examples for android.content Intent resolveActivity
public ComponentName resolveActivity(@NonNull PackageManager pm)
From source file:com.codyy.lib.utils.ActivityUtils.java
/** * ?Activity/*from w ww . j a v a2s . co m*/ * * @param context * @param packageName ?? * @param className activity?? * @return {@code true}: <br>{@code false}: ? */ public static boolean isActivityExists(Context context, String packageName, String className) { Intent intent = new Intent(); intent.setClassName(packageName, className); return !(context.getPackageManager().resolveActivity(intent, 0) == null || intent.resolveActivity(context.getPackageManager()) == null || context.getPackageManager().queryIntentActivities(intent, 0).size() == 0); }
From source file:com.hch.beautyenjoy.tools.IntentUtils.java
/** * Open system settings//from w w w. ja va 2 s . co m * * @param action The action contains global system-level device preferences. */ public static void openSettings(Context context, String action) { if (!StringUtils.isEmpty(action)) { Intent intent = new Intent(action); ComponentName componentName = intent.resolveActivity(context.getPackageManager()); if (componentName != null) { context.startActivity(intent); } } else { openSettings(context); } }
From source file:com.hch.beautyenjoy.tools.IntentUtils.java
/** * Open url in a browser/*from ww w . j av a 2 s . c om*/ */ public static void openUrl(Context context, String url) { Uri uri = Uri.parse(url); Intent intent = new Intent(Intent.ACTION_VIEW, uri); ComponentName componentName = intent.resolveActivity(context.getPackageManager()); if (componentName != null) { context.startActivity(intent); } }
From source file:com.hch.beautyenjoy.tools.IntentUtils.java
/** * Open map in a map app/*from w w w . ja va 2 s. com*/ */ public static void openMap(Context context, String parh) { Uri uri = Uri.parse(parh); Intent intent = new Intent(Intent.ACTION_VIEW, uri); ComponentName componentName = intent.resolveActivity(context.getPackageManager()); if (componentName != null) { context.startActivity(intent); } }
From source file:com.hch.beautyenjoy.tools.IntentUtils.java
/** * Open dial with a number/*from ww w . j a va2 s. c o m*/ */ public static void openDial(Context context, String number) { Uri uri = Uri.parse("tel:" + number); Intent intent = new Intent(Intent.ACTION_DIAL, uri); ComponentName componentName = intent.resolveActivity(context.getPackageManager()); if (componentName != null) { context.startActivity(intent); } }
From source file:com.hch.beautyenjoy.tools.IntentUtils.java
/** * Open dial//from w ww . j a v a2 s. c om */ public static void openDial(Context context) { Intent intent = new Intent(Intent.ACTION_CALL_BUTTON); ComponentName componentName = intent.resolveActivity(context.getPackageManager()); if (componentName != null) { context.startActivity(intent); } }
From source file:fr.free.nrw.commons.Utils.java
/** * Opens Custom Tab Activity with in-app browser for the specified URL. * Launches intent for web URL//from www . java2 s . c om * @param context * @param url */ public static void handleWebUrl(Context context, Uri url) { Timber.d("Launching web url %s", url.toString()); Intent browserIntent = new Intent(Intent.ACTION_VIEW, url); if (browserIntent.resolveActivity(context.getPackageManager()) == null) { Toast toast = Toast.makeText(context, context.getString(R.string.no_web_browser), LENGTH_SHORT); toast.show(); return; } CustomTabsIntent.Builder builder = new CustomTabsIntent.Builder(); builder.setToolbarColor(ContextCompat.getColor(context, R.color.primaryColor)); builder.setSecondaryToolbarColor(ContextCompat.getColor(context, R.color.primaryDarkColor)); builder.setExitAnimations(context, android.R.anim.slide_in_left, android.R.anim.slide_out_right); CustomTabsIntent customTabsIntent = builder.build(); // Clear previous browser tasks, so that back/exit buttons work as intended. customTabsIntent.intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK); customTabsIntent.launchUrl(context, url); }
From source file:com.hch.beautyenjoy.tools.IntentUtils.java
/** * Open camera/* w w w .j a va 2s . co m*/ */ public static void openCamera(Context context) { Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); ComponentName componentName = intent.resolveActivity(context.getPackageManager()); if (componentName != null) { context.startActivity(intent); } }
From source file:com.hch.beautyenjoy.tools.IntentUtils.java
/** * Open contact person//from w ww . j a v a 2 s. co m */ public static void openContacts(Context context) { Intent intent = new Intent(Intent.ACTION_VIEW, ContactsContract.Contacts.CONTENT_URI); ComponentName componentName = intent.resolveActivity(context.getPackageManager()); if (componentName != null) { context.startActivity(intent); } }
From source file:Main.java
/** * send a message to call the emergency with location of the accident * * @param latitude//from ww w. jav a2s .co m * @param longitude */ public static void sendEmergencyToMessages(double latitude, double longitude, Context context) { Intent sendSmsIntent = new Intent(Intent.ACTION_VIEW); sendSmsIntent.setData(Uri.parse("sms:")); sendSmsIntent.setType("vnd.android-dir/mms-sms"); String message = "The Car had accident at: " + latitude + " , " + longitude; sendSmsIntent.putExtra(Intent.EXTRA_TEXT, message); if (sendSmsIntent.resolveActivity(context.getPackageManager()) != null) { context.startActivity(sendSmsIntent); } }