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 void startActivity(Context context, Class cls, String nameFlag, Serializable serializable) {
    Intent intent = new Intent(context, cls);
    intent.putExtra(nameFlag, serializable);
    context.startActivity(intent);/*from   w w  w  .  j  av a  2 s. co  m*/
}

From source file:Main.java

/**
 * Creates an intent that will add a shortcut to the home screen.
 * @param title Title of the shortcut./*w  w  w  . ja  v  a 2s.  co  m*/
 * @param icon Image that represents the shortcut.
 * @param shortcutIntent Intent to fire when the shortcut is activated.
 * @return Intent for the shortcut.
 */
public static Intent createAddToHomeIntent(String title, Bitmap icon, Intent shortcutIntent) {
    Intent i = new Intent(INSTALL_SHORTCUT);
    i.putExtra(Intent.EXTRA_SHORTCUT_INTENT, shortcutIntent);
    i.putExtra(Intent.EXTRA_SHORTCUT_NAME, title);
    i.putExtra(Intent.EXTRA_SHORTCUT_ICON, icon);
    return i;
}

From source file:Main.java

public static Intent newEmailIntent(Context context, String address, String subject, String body, String cc) {
    Intent intent = new Intent(Intent.ACTION_SEND);
    intent.putExtra(Intent.EXTRA_EMAIL, new String[] { address });
    intent.putExtra(Intent.EXTRA_TEXT, body);
    intent.putExtra(Intent.EXTRA_SUBJECT, subject);
    intent.putExtra(Intent.EXTRA_CC, cc);
    intent.setType("message/rfc822");
    return intent;
}

From source file:Main.java

public static void displayMessage(Context context, String message) {
    // TODO: Used for basic popup messages.
    Intent intent = new Intent(DISPLAY_MESSAGE_ACTION);
    intent.putExtra(EXTRA_MESSAGE, message);
    context.sendBroadcast(intent);/*from   w ww .  java  2  s. co m*/
}

From source file:Main.java

public static Intent getSendSmsIntent(String phoneNumber, String content) {
    Uri uri = Uri.parse("smsto:" + phoneNumber);
    Intent intent = new Intent(Intent.ACTION_SENDTO, uri);
    intent.putExtra("sms_body", content);
    return intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
}

From source file:Main.java

public static void startActivity(Context context, Class cls, String nameFlag, Serializable serializable,
        int intentflag) {
    Intent intent = new Intent(context, cls);
    intent.putExtra(nameFlag, serializable);
    intent.addFlags(intentflag);/*from  w  w w.j a v a  2 s. co  m*/
    context.startActivity(intent);
}

From source file:Main.java

public static void reboot(Context context) {

    Intent intent = new Intent(Intent.ACTION_REBOOT);
    intent.putExtra("nowait", 1);
    intent.putExtra("interval", 1);
    intent.putExtra("window", 0);
    context.sendBroadcast(intent);/*from w w  w  .j  a va  2 s  .  co m*/

}

From source file:Main.java

public static void sendSms(Context context, String phoneNumber, String content) {
    Uri uri = Uri.parse("smsto:" + (TextUtils.isEmpty(phoneNumber) ? "" : phoneNumber));
    Intent intent = new Intent(Intent.ACTION_SENDTO, uri);
    intent.putExtra("sms_body", TextUtils.isEmpty(content) ? "" : content);
    context.startActivity(intent);//from  w  ww.  j  a va  2s.c  om
}

From source file:Main.java

public static void gotoActivity(Context ctx, Class<?> c, String s, boolean b) {
    Intent intent = new Intent(ctx, c);
    intent.putExtra(s, b);
    ctx.startActivity(intent);/* www  .j a  va2s.c o  m*/
    ((Activity) ctx).finish();
}

From source file:Main.java

public static void sendSMS(final Context context, String message) {
    final Intent sendIntent = new Intent(Intent.ACTION_VIEW);
    sendIntent.putExtra("sms_body", message);
    sendIntent.setType("vnd.android-dir/mms-sms");
    context.startActivity(sendIntent);//  w w w .  j  a v  a2  s.co m
}