Example usage for android.content Intent putExtra

List of usage examples for android.content Intent putExtra

Introduction

In this page you can find the example usage for android.content Intent putExtra.

Prototype

@Deprecated
@UnsupportedAppUsage
public @NonNull Intent putExtra(String name, IBinder value) 

Source Link

Document

Add extended data to the intent.

Usage

From source file:Main.java

public static Intent newSendMultipleAttachmentsIntent(String emailAddress, String subject, String contentBody,
        ArrayList<Uri> uris) {

    final Intent ei = new Intent(Intent.ACTION_SEND_MULTIPLE);
    ei.setType("plain/text");
    ei.putExtra(Intent.EXTRA_EMAIL, new String[] { emailAddress });
    ei.putExtra(Intent.EXTRA_SUBJECT, subject);

    //ei.putExtra(Intent.EXTRA_TEXT, contentBody);
    //fix for ClassCastException with Intent.EXTRA_TEXT : https://code.google.com/p/android/issues/detail?id=38303
    //: use list of string not a string
    ArrayList<String> extra_text = new ArrayList<String>();
    extra_text.add(contentBody);/*from  w  ww .ja  v a 2s. c  om*/
    ei.putExtra(Intent.EXTRA_TEXT, extra_text);

    ei.putParcelableArrayListExtra(Intent.EXTRA_STREAM, uris);

    return ei;
}

From source file:Main.java

private static Intent getAudioFileIntent(File file) {
    Intent intent = new Intent("android.intent.action.VIEW");
    intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
    intent.putExtra("oneshot", 0);
    intent.putExtra("configchange", 0);
    Uri uri = Uri.fromFile(file);//ww w .j  a v a2s  . c  o m
    intent.setDataAndType(uri, "audio/*");
    return intent;
}

From source file:Main.java

private static Intent getVideoFileIntent(File file) {
    Intent intent = new Intent("android.intent.action.VIEW");
    intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
    intent.putExtra("oneshot", 0);
    intent.putExtra("configchange", 0);
    Uri uri = Uri.fromFile(file);//from w w w  .  j a v a2s  .co  m
    intent.setDataAndType(uri, "video/*");
    return intent;
}

From source file:Main.java

private static Intent getVideoFileIntent(String filePath) {

    Intent intent = new Intent("android.intent.action.VIEW");
    intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
    intent.putExtra("oneshot", 0);
    intent.putExtra("configchange", 0);
    Uri uri = Uri.fromFile(new File(filePath));
    intent.setDataAndType(uri, "video/*");
    return intent;
}

From source file:Main.java

public static void startAR(Activity activity, Class<?> c, int requestCode, BasicNameValuePair... name) {
    Intent intent = new Intent();
    intent.setClass(activity, c);//from   w w  w  . ja  va  2s  . co  m
    for (int i = 0; i < name.length; i++) {
        intent.putExtra(name[i].getName(), name[i].getValue());
    }
    activity.startActivityForResult(intent, requestCode);
}

From source file:Main.java

public static Intent getInputLanguageSelectionIntent(String inputMethodId, int flagsForSubtypeSettings) {
    // Refer to android.provider.Settings.ACTION_INPUT_METHOD_SUBTYPE_SETTINGS
    final String action = INPUT_METHOD_SUBTYPE_SETTINGS;
    final Intent intent = new Intent(action);
    if (!TextUtils.isEmpty(inputMethodId)) {
        intent.putExtra(EXTRA_INPUT_METHOD_ID, inputMethodId);
    }/*from w ww  .ja v a  2 s .  c o m*/
    if (flagsForSubtypeSettings > 0) {
        intent.setFlags(flagsForSubtypeSettings);
    }
    return intent;
}

From source file:Main.java

public static Intent getAudioFileIntent(String param) {

    Intent intent = new Intent("android.intent.action.VIEW");
    intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
    intent.putExtra("oneshot", 0);
    intent.putExtra("configchange", 0);
    Uri uri = Uri.fromFile(new File(param));
    intent.setDataAndType(uri, "audio/*");
    return intent;
}

From source file:Main.java

public static void sendMail(Context context, String dstAddr, String subject, String text) {
    final Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);

    String[] address = { dstAddr };
    emailIntent.putExtra(Intent.EXTRA_EMAIL, address);
    emailIntent.setType("message/rfc822");
    emailIntent.putExtra(Intent.EXTRA_SUBJECT, subject);
    emailIntent.putExtra(Intent.EXTRA_TEXT, text);
    context.startActivity(Intent.createChooser(emailIntent, "Send mail..."));
}

From source file:Main.java

/**
 * Create a precondition activity intent.
 * //  w  w  w. java2s  .c o m
 * @param activity
 *            the original activity
 * @param preconditionActivityClazz
 *            the precondition activity's class
 * @return an intent which will launch the precondition activity.
 */
public static Intent createPreconditionIntent(Activity activity, Class<?> preconditionActivityClazz) {
    Intent newIntent = new Intent();
    newIntent.setClass(activity, preconditionActivityClazz);
    newIntent.putExtra(EXTRA_WRAPPED_INTENT, activity.getIntent());
    return newIntent;
}

From source file:Main.java

private static void setBadgeSamsung(Context context, int count) {
    String launcherClassName = getLauncherClassName(context);
    if (launcherClassName == null) {
        return;/* w  w w  .  j ava  2  s  .  co m*/
    }

    Intent intent = new Intent("android.intent.action.BADGE_COUNT_UPDATE");
    intent.putExtra("badge_count", count);
    intent.putExtra("badge_count_package_name", context.getPackageName());
    intent.putExtra("badge_count_class_name", launcherClassName);
    context.sendBroadcast(intent);
}