List of usage examples for android.content Intent putExtra
@Deprecated
@UnsupportedAppUsage
public @NonNull Intent putExtra(String name, IBinder value)
From source file:Main.java
public static void jumpToSystemShareText(Context context, String content) { Intent sendIntent = new Intent(); sendIntent.setAction("android.intent.action.SEND"); sendIntent.putExtra("android.intent.extra.TEXT", content); sendIntent.setType("text/plain"); context.startActivity(sendIntent);//from w w w .j a v a 2 s .c o m }
From source file:Main.java
public static void installLaunchShortCut(Context context, Intent intent, String shortCutName, Bitmap icon, boolean duplicate) { Intent shortCutIntent = new Intent("com.android.launcher.action.INSTALL_SHORTCUT"); shortCutIntent.putExtra(Intent.EXTRA_SHORTCUT_NAME, shortCutName); shortCutIntent.putExtra(Intent.EXTRA_SHORTCUT_ICON, icon); shortCutIntent.putExtra("duplicate", duplicate); intent.setAction(Intent.ACTION_MAIN); shortCutIntent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, intent); context.sendBroadcast(shortCutIntent); }
From source file:Main.java
public static void sendTo(Context ctx, String sendWhat) { Intent shareIntent = new Intent(Intent.ACTION_SEND); shareIntent.setType("text/plain"); shareIntent.putExtra(Intent.EXTRA_TEXT, sendWhat); ctx.startActivity(shareIntent);/*from w ww . j a v a 2s .com*/ }
From source file:Main.java
public static Intent buildVideoIntent(Context context, Uri uri) { String title = "Choose photo"; //Build galleryIntent Intent galleryIntent = new Intent(Intent.ACTION_PICK); galleryIntent.setType("video/*"); //Create chooser Intent chooser = Intent.createChooser(galleryIntent, title); Intent cameraIntent = new Intent(MediaStore.ACTION_VIDEO_CAPTURE); cameraIntent.putExtra(MediaStore.EXTRA_OUTPUT, uri); Intent[] extraIntents = { cameraIntent }; chooser.putExtra(Intent.EXTRA_INITIAL_INTENTS, extraIntents); return chooser; }
From source file:Main.java
/** Launch an email intent if the device is capable. * * @param activity The parent activity (for context) * @param addr The address to email (not the full URI) * @param text The email body// w w w.jav a 2 s . c o m */ public static void launchEmailIntent(final Activity activity, String addr, String text) { Log.i(LOG_TAG, "Launch email intent from " + activity.getLocalClassName()); // create email intent Intent emailIntent = new Intent(Intent.ACTION_SEND); emailIntent.putExtra(Intent.EXTRA_EMAIL, new String[] { addr }); emailIntent.setType("text/plain"); // make sure there is an activity which can handle the intent. PackageManager emailpackageManager = activity.getPackageManager(); List<ResolveInfo> emailresolveInfos = emailpackageManager.queryIntentActivities(emailIntent, 0); if (emailresolveInfos.size() > 0) { activity.startActivity(emailIntent); } }
From source file:Main.java
public static void jumpToSystemShareImage(Context context, String imageUri) { Intent shareIntent = new Intent(); shareIntent.setAction("android.intent.action.SEND"); shareIntent.putExtra("android.intent.extra.STREAM", imageUri); shareIntent.setType("image/*"); context.startActivity(shareIntent);/*from ww w . j av a 2s.c om*/ }
From source file:Main.java
public static void forward(Context context, String body) { if (body != null) { Intent intent = new Intent(Intent.ACTION_SEND); intent.setType("text/plain"); intent.putExtra(Intent.EXTRA_TEXT, body); context.startActivity(intent);/*from w ww . ja v a2 s .c om*/ } }
From source file:Main.java
public static void shareToOtherApp(Context context, String title, String content, String dialogTitle) { Intent intentItem = new Intent(Intent.ACTION_SEND); intentItem.setType("text/plain"); intentItem.putExtra(Intent.EXTRA_SUBJECT, title); intentItem.putExtra(Intent.EXTRA_TEXT, content); intentItem.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); context.startActivity(Intent.createChooser(intentItem, dialogTitle)); }
From source file:Main.java
/** * Trigger the intent to open the system dialog that asks the user to change the default * SMS app./*from ww w . j a v a2 s. com*/ * @param context The Context */ public static void setDefaultSmsApp(Context context) { // This is a new intent which only exists on KitKat if (hasKitKat()) { Intent intent = new Intent(Intents.ACTION_CHANGE_DEFAULT); intent.putExtra(Intents.EXTRA_PACKAGE_NAME, context.getPackageName()); context.startActivity(intent); } }
From source file:Main.java
public static void share(Context context, String title, String url) { Intent shareIntent = new Intent(Intent.ACTION_SEND); shareIntent.setType("text/plain"); shareIntent.putExtra(Intent.EXTRA_TEXT, url); Intent chooserIntent = Intent.createChooser(shareIntent, title); chooserIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); context.startActivity(chooserIntent); }