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:com.android.utils.labeling.LabelOperationUtils.java

public static boolean startActivityEditLabel(Context context, Label label) {
    if (context == null || label == null) {
        return false;
    }//from ww  w.j  a v  a2s.c  o  m

    final Intent editIntent = new Intent(ACTION_EDIT_LABEL);
    final Bundle extras = new Bundle();
    extras.putLong(EXTRA_LONG_LABEL_ID, label.getId());
    editIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    editIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
    editIntent.putExtras(extras);

    try {
        context.startActivity(editIntent);
        return true;
    } catch (Exception e) {
        e.printStackTrace();
        return false;
    }
}

From source file:Main.java

public static void sendSchemeAddMediaStack(Context context, String mediaActivityUrl, String url,
        Bundle bundle) {//from  w  ww.  j  av a2s  .c  o m
    Intent intent = new Intent("android.intent.action.VIEW", Uri.parse(mediaActivityUrl));
    intent.addFlags(67108864);
    context.startActivity(intent);
    intent = new Intent("android.intent.action.VIEW", Uri.parse(url));
    if (bundle != null) {
        intent.putExtras(bundle);
    }

    context.startActivity(intent);
}

From source file:Main.java

@SuppressLint("NewApi")
public static void sendSchemeAddMediaStack(Fragment context, String mediaActivityUrl, String url,
        Bundle bundle) {/*from ww w .j a  v  a  2 s  .  c om*/
    Intent intent = new Intent("android.intent.action.VIEW", Uri.parse(mediaActivityUrl));
    intent.addFlags(67108864);
    context.startActivity(intent);
    intent = new Intent("android.intent.action.VIEW", Uri.parse(url));
    if (bundle != null) {
        intent.putExtras(bundle);
    }

    context.startActivity(intent);
}

From source file:com.android.utils.labeling.LabelOperationUtils.java

public static boolean startActivityRemoveLabel(Context context, Label label) {
    if (context == null || label == null) {
        return false;
    }/*from  www  .jav  a  2 s.  c o m*/

    final Intent removeIntent = new Intent(ACTION_REMOVE_LABEL);
    final Bundle extras = new Bundle();
    extras.putLong(EXTRA_LONG_LABEL_ID, label.getId());
    removeIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    removeIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
    removeIntent.putExtras(extras);

    try {
        context.startActivity(removeIntent);
        return true;
    } catch (Exception e) {
        e.printStackTrace();
        return false;
    }
}

From source file:com.github.jorgecastilloprz.corleone.sample.ui.activity.GameDetailsActivity.java

public static Intent getLaunchIntent(final Context context, Game game) {
    if (game == null) {
        throwIllegalArgExceptionForNullGame();
    }//  w ww .  ja  v  a  2s.  c  o  m
    Intent intent = new Intent(context, GameDetailsActivity.class);
    Bundle bundle = new Bundle();
    bundle.putParcelable(GAME_EXTRA, Parcels.wrap(game));
    return intent.putExtras(bundle);
}

From source file:com.android.utils.labeling.LabelOperationUtils.java

public static boolean startActivityAddLabelForNode(Context context, AccessibilityNodeInfoCompat node) {
    if (context == null || node == null) {
        return false;
    }//  ww w .  ja v a  2s  .co m

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
        final Intent addIntent = new Intent(ACTION_ADD_LABEL);
        final Bundle extras = new Bundle();
        extras.putString(EXTRA_STRING_RESOURCE_NAME, node.getViewIdResourceName());
        addIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        addIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
        addIntent.putExtras(extras);

        try {
            context.startActivity(addIntent);
            return true;
        } catch (Exception e) {
            e.printStackTrace();
            return false;
        }
    } else {
        return false;
    }
}

From source file:com.carpool.dj.carpool.model.GcmIntentService.java

/**
 * Issues a notification to inform the user that server has sent a message.
 *//*www .  j a  va2  s . c  om*/
@SuppressWarnings("deprecation")
private static void generateNotification(Context context, String message, Bundle data, String type) {

    int icon = R.drawable.ic_launcher;
    long when = System.currentTimeMillis();
    Uri alarmSound = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
    NotificationManager notificationManager = (NotificationManager) context
            .getSystemService(Context.NOTIFICATION_SERVICE);
    // Notification notification = new Notification(icon, message, when);
    Notification notification = new Notification.Builder(context)
            .setContentTitle(Utils.nowActivity.getString(R.string.app_name)).setContentText(message)
            .setSmallIcon(icon).setWhen(when).setSound(alarmSound).build();

    // String title = context.getString(R.string.app_name);

    Intent notificationIntent = null;
    if ("CarEvent".equals(type)) {
        notificationIntent = new Intent(context, ContentActivity.class);
    } else {
        return;
    }
    notificationIntent.putExtras(data);
    // set intent so it does not start a new activity
    notificationIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
    PendingIntent intent = PendingIntent.getActivity(context, 0, notificationIntent,
            PendingIntent.FLAG_UPDATE_CURRENT);
    notification.setLatestEventInfo(context, Utils.nowActivity.getString(R.string.app_name), message, intent);
    notification.flags |= Notification.FLAG_AUTO_CANCEL;

    notificationManager.notify(0, notification);

}

From source file:Main.java

public static void actionStart(Activity activity, Class cls, Bundle bundle, int... intentFlags) {
    Intent intent = new Intent(activity, cls);
    if (intentFlags != null) {
        for (int i = 0; i < intentFlags.length; i++) {
            if (intentFlags[i] != 0) {
                if (i == 0) {
                    intent.setFlags(intentFlags[i]);
                } else {
                    intent.addFlags(intentFlags[i]);
                }/*from  ww w.  ja  v  a2 s . co m*/
            }
        }
    }
    if (bundle != null) {
        intent.putExtras(bundle);
    }
    activity.startActivity(intent);
}

From source file:com.fastaccess.ui.modules.repos.RepoPagerView.java

public static Intent createIntent(@NonNull Context context, @NonNull String repoId, @NonNull String login,
        @RepoPagerMvp.RepoNavigationType int navType) {
    Intent intent = new Intent(context, RepoPagerView.class);
    intent.putExtras(Bundler.start().put(BundleConstant.ID, repoId).put(BundleConstant.EXTRA_TWO, login)
            .put(BundleConstant.EXTRA_TYPE, navType).end());
    return intent;
}

From source file:com.aqtx.app.main.activity.MainActivity.java

public static void start(Context context, Intent extras) {
    Intent intent = new Intent();
    intent.setClass(context, MainActivity.class);
    intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
    if (extras != null) {
        intent.putExtras(extras);
    }//  w  ww .  j a  va 2 s  .c  om
    context.startActivity(intent);
}