List of usage examples for android.content Intent setType
public @NonNull Intent setType(@Nullable String type)
From source file:Main.java
public static void mail(Activity activity, String email, String subject, String content) { Intent intent = new Intent(Intent.ACTION_SEND); intent.setType("text/plain"); intent.putExtra(Intent.EXTRA_EMAIL, new String[] { email }); intent.putExtra(Intent.EXTRA_SUBJECT, subject); if (content != null) { intent.putExtra(Intent.EXTRA_TEXT, content); }/*from w w w. j a va 2 s .c o m*/ final PackageManager manager = activity.getPackageManager(); final List<ResolveInfo> matches = manager.queryIntentActivities(intent, 0); for (ResolveInfo info : matches) { if (info.activityInfo.packageName.endsWith(".gm") || info.activityInfo.name.toLowerCase().contains("gmail")) { intent.setClassName(info.activityInfo.packageName, info.activityInfo.name); } else if (info.activityInfo.packageName.endsWith(".email") || info.activityInfo.name.toLowerCase().contains("email")) { intent.setClassName(info.activityInfo.packageName, info.activityInfo.name); } } activity.startActivity(intent); }
From source file:Main.java
public static Intent getImageFromGallery() { Intent intent = new Intent(Intent.ACTION_PICK, MediaStore.Images.Media.EXTERNAL_CONTENT_URI); intent.setType("image/*"); return intent; }
From source file:Main.java
@SuppressLint("InlinedApi") public static void launchPlainText(Context context, String text, CharSequence chooserTitle) { // See http://android-developers.blogspot.com/2012/02/share-with-intents.html Intent intent = new Intent(android.content.Intent.ACTION_SEND); intent.setType("text/plain"); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_DOCUMENT); intent.putExtra(Intent.EXTRA_TEXT, text); // intent.putExtra( Intent.EXTRA_SUBJECT, subject ); // intent.putExtra( Intent.EXTRA_EMAIL, new String[] { emailTo } ); context.startActivity(Intent.createChooser(intent, chooserTitle)); }
From source file:Main.java
public static void startMessageActivity(Context context) { Intent it = new Intent(Intent.ACTION_VIEW); it.putExtra("sms_body", "The SMS text"); it.setType("vnd.android-dir/mms-sms"); context.startActivity(it);/* w w w .j a v a 2s .c o m*/ }
From source file:Main.java
/** * @brief Get the intent to add telephone number into contact. * * @par Sync (or) Async:/* www .j a v a 2 s . com*/ * This is a Synchronous function. * * @param [IN] telNumber Telephone number.\n * * @return * * @author daiping.zhao * @since 1.0.0.0 * @version 1.0.0.0 * @par Prospective Clients: * External Classes */ public static Intent doAddTelToExistContact(String telNumber) { Intent newIntent = new Intent(Intent.ACTION_INSERT_OR_EDIT, Contacts.CONTENT_URI); newIntent.setType(Contacts.CONTENT_ITEM_TYPE); newIntent.putExtra(Intents.Insert.PHONE, telNumber); return newIntent; }
From source file:Main.java
/** * @brief Get the intent to add email address to existed contact. * * @par Sync (or) Async:/*from w ww . ja v a2 s.co m*/ * This is a Synchronous function. * * @param [IN] email email address.\n * * @return * * @author daiping.zhao * @since 1.0.0.0 * @version 1.0.0.0 * @par Prospective Clients: * External Classes */ public static Intent doAddEmaliToExistContact(String email) { Intent newIntent = new Intent(Intent.ACTION_INSERT_OR_EDIT, Contacts.CONTENT_URI); newIntent.setType(Contacts.CONTENT_ITEM_TYPE); newIntent.putExtra(Intents.Insert.EMAIL, email); return newIntent; }
From source file:Main.java
/** * Lancia la finestra per la selezione di un gestore per la condivisione di un messaggio * (twitter, facebook, ....).//www.j a va 2 s . c o m * * @param context * @param dialogTitle - Titolo della finestra di dialog (Share...) * @param subject - Subject (della email o titolo di twitter) * @param text - Testo del messaggio */ public static void share(Context context, String dialogTitle, String subject, String text) { final Intent intent = new Intent(Intent.ACTION_SEND); intent.setType("text/plain"); intent.putExtra(Intent.EXTRA_SUBJECT, subject); intent.putExtra(Intent.EXTRA_TEXT, text); context.startActivity(Intent.createChooser(intent, dialogTitle)); }
From source file:Main.java
public static void takePhotoFromAbnum(Activity activity) { Intent intent = new Intent(Intent.ACTION_GET_CONTENT, MediaStore.Images.Media.EXTERNAL_CONTENT_URI); intent.setType("image/*"); activity.startActivityForResult(intent, TAKE_PHOTO_FROM_ALBUM); }
From source file:Main.java
/** * Share the crisis with your friend and/or the world. *///from www. j a v a2 s. co m public static Intent shareCrisis(String crisisID, String shortTitle) { Intent shareIntent = new Intent(android.content.Intent.ACTION_SEND); shareIntent.setType("text/plain"); StringBuffer shareContent = new StringBuffer(); shareContent.append(shortTitle); shareContent.append(" - "); shareContent.append("http://www.sigimera.org/crises/"); shareContent.append(crisisID); shareIntent.putExtra(android.content.Intent.EXTRA_TEXT, shareContent.toString()); return shareIntent; }
From source file:Main.java
public static void addToFacebookContact(Context mContext, ArrayList<String> contactDatas) { /**// www. j av a 2 s. c o m * ArrayList elements: * * 1. Name 2. Userid 3.Username */ Intent i = new Intent(Intent.ACTION_INSERT_OR_EDIT); i.setType(ContactsContract.Contacts.CONTENT_ITEM_TYPE); if (contactDatas.get(2) == null) { contactDatas.set(2, "Facebook name"); } ArrayList<ContentValues> data = new ArrayList<ContentValues>(); ContentValues row1 = new ContentValues(); row1.put(ContactsContract.Data.MIMETYPE, ContactsContract.CommonDataKinds.Im.CONTENT_ITEM_TYPE); row1.put(ContactsContract.Data.DATA1, contactDatas.get(2)); row1.put(ContactsContract.Data.DATA2, ContactsContract.CommonDataKinds.Im.TYPE_OTHER); row1.put(ContactsContract.Data.DATA5, ContactsContract.CommonDataKinds.Im.PROTOCOL_CUSTOM); row1.put(ContactsContract.Data.DATA6, "Facebook"); row1.put(ContactsContract.Data.DATA10, contactDatas.get(1)); data.add(row1); i.putExtra(Insert.NAME, contactDatas.get(0)); i.putParcelableArrayListExtra(ContactsContract.Intents.Insert.DATA, data); mContext.startActivity(i); }