Example usage for android.content Intent putExtras

List of usage examples for android.content Intent putExtras

Introduction

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

Prototype

public @NonNull Intent putExtras(@NonNull Bundle extras) 

Source Link

Document

Add a set of extended data to the intent.

Usage

From source file:Main.java

public static void changeActivity(FragmentActivity source, Class<?> destination, boolean shouldFinishContext,
        Bundle bundle) {// w ww.  j a  v a 2 s  . c  om
    if (shouldFinishContext) {
        source.finish();
    }
    Intent intent = new Intent(source, destination);
    intent.putExtras(bundle);
    source.startActivity(intent);
}

From source file:Main.java

public static void launchActivity(Context context, Class<?> activity, Bundle bundle) {
    Intent intent = new Intent(context, activity);
    intent.putExtras(bundle);
    context.startActivity(intent);//ww w. j  a  va  2  s  . com
}

From source file:Main.java

public static void goActivity(Context context, Class<?> cls, Bundle bundle) {
    Intent intent = new Intent(context, cls);
    if (null != bundle) {
        intent.putExtras(bundle);
    }/*from w  w  w  .j ava  2  s  .c o m*/

    context.startActivity(intent);
}

From source file:Main.java

/**
 * Notifies UI to display a message./*from  w  ww .  java 2  s. c o  m*/
 * <p>
 * This method is defined in the common helper because it's used both by
 * the UI and the background service.
 *
 * @param context application's context.
 * @param message message to be displayed.
 */
static void displayMessage(Context context, Bundle extras) {
    Intent intent = new Intent(DISPLAY_MESSAGE_ACTION);
    intent.putExtras(extras);
    context.sendBroadcast(intent);
}

From source file:Main.java

public static void goToForResult(Activity aty, Class clazz, Bundle bundle, int requestCode) {
    Intent intent = new Intent(aty, clazz);
    if (bundle != null) {
        intent.putExtras(bundle);
    }//from www . java2s  .c om
    aty.startActivityForResult(intent, requestCode);
}

From source file:Main.java

private static Intent getComponentIntent(String packageName, String className, Bundle bundle) {
    Intent intent = new Intent(Intent.ACTION_VIEW);
    if (bundle != null)
        intent.putExtras(bundle);
    ComponentName cn = new ComponentName(packageName, className);
    intent.setComponent(cn);//from   w  w w .  j a  va  2  s . co m
    return intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
}

From source file:Main.java

public static <T extends Activity> void start(Activity caller, Class<T> activityClass, Bundle params) {
    Intent intent = new Intent(caller, activityClass);
    if (params != null) {
        intent.putExtras(params);
    }/*from   w  ww. j  av a2s  .  com*/
    caller.startActivity(intent);
}

From source file:Main.java

public static Intent getComponentIntent(String packageName, String className, Bundle bundle) {
    Intent intent = new Intent(Intent.ACTION_VIEW);
    if (bundle != null)
        intent.putExtras(bundle);
    ComponentName cn = new ComponentName(packageName, className);
    intent.setComponent(cn);//from   w  w w  .j a  v  a  2s .c  o m
    return intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
}

From source file:Main.java

public static void openActivityForResult(Activity context, Class<?> activity, Bundle b, int requestCode) {
    Intent intent = new Intent(context, activity);
    if (b != null)
        intent.putExtras(b);
    context.startActivityForResult(intent, requestCode);
}

From source file:Main.java

public static void transferData(Intent oldIntent, Intent newIntent) {
    if (oldIntent == null) {
        return;//from   w w w. j  a va2  s  .  co m
    }

    newIntent.putExtras(oldIntent);
}