List of usage examples for android.content Intent setData
public @NonNull Intent setData(@Nullable Uri data)
From source file:Main.java
/** * Returns an implicit intent for opening QuickContacts. *///from w w w . j av a 2 s . c o m public static Intent composeQuickContactIntent(Uri contactLookupUri, int extraMode) { final Intent intent = new Intent(QuickContact.ACTION_QUICK_CONTACT); intent.setData(contactLookupUri); intent.putExtra(QuickContact.EXTRA_MODE, extraMode); // Make sure not to show QuickContacts on top of another QuickContacts. intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); return intent; }
From source file:Main.java
/** * @param activity/*from w w w .j a v a 2 s .c om*/ * @param phone */ public static void phone(Activity activity, String phone) { phone = "tel:" + phone.trim(); Intent intent = new Intent(); intent.setAction(Intent.ACTION_VIEW); intent.setData(Uri.parse(phone)); activity.startActivity(intent); }
From source file:Main.java
public static void startPhone(Context context, String phoneNumber) { Intent intent = new Intent(Intent.ACTION_DIAL); // intent.setAction(Intent.ACTION_CALL); intent.setData(Uri.parse("tel:" + phoneNumber)); context.startActivity(intent);/*from w w w . ja v a 2 s . c om*/ }
From source file:Main.java
public static void callPhone(Context context, String phone) { Intent intent = new Intent(Intent.ACTION_CALL); Uri data = Uri.parse("tel:" + phone); intent.setData(data); context.startActivity(intent);/*w w w . java 2 s. co m*/ }
From source file:Main.java
public static void startDialer(Context context, String phoneNumber) { try {//from w ww . j a va2s .c om Intent dial = new Intent(); dial.setAction(Intent.ACTION_DIAL); dial.setData(Uri.parse("tel:" + phoneNumber)); context.startActivity(dial); } catch (Exception ex) { Log.e(TAG, "Error starting phone dialer intent.", ex); Toast.makeText(context, "Sorry, we couldn't find any app to place a phone call!", Toast.LENGTH_SHORT) .show(); } }
From source file:Main.java
/** * Builds an Intent to add a new event to the calendar. * * @param title The title of the event.//w w w. j a v a 2s . co m * @param start The start date and time. * @param end The end date and time. * @param where Where the event is held (e.g.: an address). */ public static Intent getAddEventIntent(final String title, final Date start, final Date end, final String where) { Intent intent = new Intent(Intent.ACTION_INSERT); intent.setData(CalendarContract.Events.CONTENT_URI); intent.putExtra(CalendarContract.EXTRA_EVENT_BEGIN_TIME, start.getTime()); intent.putExtra(CalendarContract.EXTRA_EVENT_END_TIME, end.getTime()); intent.putExtra(CalendarContract.Events.TITLE, title); if (where != null) { intent.putExtra(CalendarContract.Events.EVENT_LOCATION, where); } return intent; }
From source file:Main.java
public static ResolveInfo getDefaultBrowser(Context context) { PackageManager pm = context.getPackageManager(); Intent query = new Intent(); query.setAction(Intent.ACTION_VIEW); query.setData(Uri.parse("http://localhost")); ResolveInfo info = pm.resolveActivity(query, 0); if (info == null) { return info; }/*from w w w . j a va2 s . c o m*/ // Could be a Chooser if (info.activityInfo.packageName.equals("android")) { return null; } return info; }
From source file:Main.java
/** * Checks if there is any of the CFI apps installed on the device supports PBBA payment. * * @param context application context/*from w w w . j a v a 2 s .c o m*/ * @return true if available */ public static boolean isZappCFIAppAvailable(@NonNull final Context context) { final Intent zappIntent = new Intent(); zappIntent.setAction(Intent.ACTION_VIEW); zappIntent.setData(new Uri.Builder().scheme(ZAPP_SCHEME).build()); final ResolveInfo resolveInfo = context.getPackageManager().resolveActivity(zappIntent, PackageManager.MATCH_DEFAULT_ONLY); return resolveInfo != null; }
From source file:Main.java
public static void showDownloadSetting(Context context) { String packageName = "com.android.providers.downloads"; Intent intent = new Intent(android.provider.Settings.ACTION_APPLICATION_DETAILS_SETTINGS); intent.setData(Uri.parse("package:" + packageName)); if (intentAvailable(context, intent)) { context.startActivity(intent);/* w w w. j av a 2 s. c o m*/ } }
From source file:Main.java
public static void showAppInfo(String packageName, Context context) { Intent intent = new Intent(); intent.setAction("android.settings.APPLICATION_DETAILS_SETTINGS"); intent.setData(Uri.parse("package:" + packageName)); context.startActivity(intent);/*from w w w . ja va 2 s . c o m*/ }