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

/**
 * Notifies UI to display a message.//from   ww  w  .ja v  a 2 s .com
 * 
 * @param context
 *            - application's context
 * @param message
 *            - message to be displayed
 */
static void displayMessage(Context context, String message) {
    Intent intent = new Intent();
    intent.putExtra(EXTRA_MESSAGE, message);
    context.sendBroadcast(intent);
}

From source file:Main.java

/**
 * Broadcast data as a message/*from   w  ww .ja va2 s  .  c  om*/
 *
 * @param context
 *     the context
 * @param data
 *     the data
 * @param action
 *     the action
 * @param custompermission
 *     the custompermission
 */
public static void broadcastData(Context context, String data, String action, String custompermission) {
    Intent i = new Intent();
    i.putExtra("data", data);
    i.setAction(action); // action ~ "com.example.android.action"
    context.sendBroadcast(i, custompermission); // custompermisson ~ "com.example.permission.MY_PERMISSION"
}

From source file:Main.java

public static void onActivityResult(Activity activity, Intent data) {
    if (data != null) {
        Intent i = activity.getIntent();
        i.putExtra(EXTRA_FORWARD_INTENT, data);
        activity.setResult(0, i);/*from ww w. java2s . co  m*/
    }
}

From source file:Main.java

public static final void setLaunchThroughStatusBar(Intent intent, long launchThroughStatusBar) {
    intent.putExtra(EXTRA_LAUNCH_THROUGH_STATUS_BAR, launchThroughStatusBar);
}

From source file:Main.java

public static void jumpAndId(Context context, Class cla, String nid) {
    Intent intent = new Intent(context, cla);
    intent.putExtra("nid", nid);
    context.startActivity(intent);//from w w  w .  j a v a  2 s . co m
}

From source file:Main.java

public static void launchBroadcast(Context context, String intentType, String messageType, String message) {
    Intent intent = new Intent(intentType);
    intent.putExtra(messageType, message);
    LocalBroadcastManager broadcaster = LocalBroadcastManager.getInstance(context);
    broadcaster.sendBroadcast(intent);/*from   w  w  w . ja  v  a  2  s .co  m*/
}

From source file:Main.java

public static final void invokeWithArgs(Activity activity, Class<?> clazz, Bundle bundle) {
    Intent intent = new Intent(activity, clazz);
    intent.putExtra("bundle", bundle);
    activity.startActivity(intent);/*from ww w  . java  2  s .c  o  m*/
}

From source file:Main.java

public static void startActivityForResult(Activity context, Class<?> cls, String data, int flag) {
    Intent intent = new Intent(context, cls);
    intent.putExtra("data", data);
    intent.setFlags(flag);//from  w w w. j  av  a 2  s .c o  m
    context.startActivityForResult(intent, flag);
}

From source file:Main.java

public static Intent createButtonIntent(String buttonText, String intentActionName) {
    Intent intent = new Intent(intentActionName);
    intent.putExtra("button_text", buttonText);
    return intent;
}

From source file:Main.java

public static void startActivityForResult(Activity activity, Class<?> cls, String data, int flag) {
    Intent intent = new Intent(activity, cls);
    intent.putExtra("data", data);
    intent.setFlags(flag);//w w w .j  a v  a2 s . com
    activity.startActivityForResult(intent, flag);
}