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:amhamogus.com.daysoff.CalendarActivity.java

public void onCalendarSelected(Date date, EventCollection eventCollection) {

    Bundle bundle = new Bundle();
    bundle.putLong(ARG_CURRENT_DATE, date.getTime());

    SharedPreferences.Editor editor = settings.edit();
    editor.putLong(PREF_SELECTED_DATE, date.getTime());
    editor.commit();/*from w  w  w  .ja  v a 2s .c o m*/

    Intent intent = new Intent(getApplicationContext(), EventsActivity.class);
    intent.putExtras(bundle);
    startActivity(intent);
}

From source file:mx.itdurango.rober.siitdocentes.asynctasks.ParcialesTask.java

@Override
protected void onPostExecute(String resultado) {
    super.onPostExecute(resultado);
    Intent intent = new Intent(context, ActivityAlumnos.class);
    Bundle bundle = new Bundle();
    bundle.putString("resultado", resultado);
    intent.putExtras(bundle);
    context.startActivity(intent);/* w  ww .ja  va2  s.  c om*/
    Estaticos.ringProgressDialog.dismiss();
}

From source file:com.example.android.popularmovies.activities.MovieDetailsActivity.java

private void onRestore(Bundle savedInstanceState) {
    if (savedInstanceState != null) {
        if (savedInstanceState.containsKey(MOVIE_ACTIVE)) {
            mMovie = savedInstanceState.getParcelable(MOVIE_ACTIVE);
        }/* w  ww .j a  v  a  2  s  .  co m*/
    }
    //If pane layout recreate activity.
    if (mIsPaneLayout) {
        Log.d(MovieDetailsActivity.TAG, "Recreating activity in pane layout");
        Intent mainActivityIntent = new Intent(this, MainActivity.class);
        mainActivityIntent.putExtras(savedInstanceState);
        startActivity(mainActivityIntent);
    }
    setupFragments();
}

From source file:com.geekandroid.sdk.sample.JPushReceiver.java

@Override
public void onReceive(Context context, Intent intent) {
    Bundle bundle = intent.getExtras();//from  www.j  av a 2 s .c om
    Log.d(TAG, "[JPushReceiver] onReceive - " + intent.getAction() + ", extras: " + printBundle(bundle));

    if (JPushInterface.ACTION_REGISTRATION_ID.equals(intent.getAction())) {
        String regId = bundle.getString(JPushInterface.EXTRA_REGISTRATION_ID);
        Log.d(TAG, "[JPushReceiver] Registration Id : " + regId);
        //send the Registration Id to your server...

    } else if (JPushInterface.ACTION_MESSAGE_RECEIVED.equals(intent.getAction())) {
        Log.d(TAG, "[JPushReceiver] ???: "
                + bundle.getString(JPushInterface.EXTRA_MESSAGE));
        processCustomMessage(context, bundle);

    } else if (JPushInterface.ACTION_NOTIFICATION_RECEIVED.equals(intent.getAction())) {
        Log.d(TAG, "[JPushReceiver] ??");
        int notifactionId = bundle.getInt(JPushInterface.EXTRA_NOTIFICATION_ID);
        Log.d(TAG, "[JPushReceiver] ??ID: " + notifactionId);

    } else if (JPushInterface.ACTION_NOTIFICATION_OPENED.equals(intent.getAction())) {
        Log.d(TAG, "[JPushReceiver] ");
        JPushImpl.getInstance().clearAllNotifications();

        //Activity
        Intent i = new Intent(context, JPushOpenActivity.class);
        i.putExtras(bundle);
        //i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP);
        context.startActivity(i);

    } else if (JPushInterface.ACTION_RICHPUSH_CALLBACK.equals(intent.getAction())) {
        Log.d(TAG, "[JPushReceiver] RICH PUSH CALLBACK: "
                + bundle.getString(JPushInterface.EXTRA_EXTRA));
        //? JPushInterface.EXTRA_EXTRA ??Activity ..

    } else if (JPushInterface.ACTION_CONNECTION_CHANGE.equals(intent.getAction())) {
        boolean connected = intent.getBooleanExtra(JPushInterface.EXTRA_CONNECTION_CHANGE, false);
        Log.w(TAG, "[JPushReceiver]" + intent.getAction() + " connected state change to " + connected);
    } else {
        Log.d(TAG, "[JPushReceiver] Unhandled intent - " + intent.getAction());
    }
}

From source file:cn.chenzhongjin.eventbus.sample.ui.base.BaseFragment.java

/**
 * startActivity with bundle//  w w w  . ja v a  2  s  .  c om
 *
 * @param clazz
 * @param bundle
 */
protected void readyGo(Class<?> clazz, Bundle bundle) {
    Intent intent = new Intent(getActivity(), clazz);
    if (null != bundle) {
        intent.putExtras(bundle);
    }
    startActivity(intent);
}

From source file:cn.chenzhongjin.eventbus.sample.ui.base.BaseFragment.java

/**
 * startActivityForResult with bundle/*w w w .  ja v a 2  s .  c om*/
 *
 * @param clazz
 * @param requestCode
 * @param bundle
 */
protected void readyGoForResult(Class<?> clazz, int requestCode, Bundle bundle) {
    Intent intent = new Intent(getActivity(), clazz);
    if (null != bundle) {
        intent.putExtras(bundle);
    }
    startActivityForResult(intent, requestCode);
}

From source file:ca.ualberta.cmput301.as1.czervos_notes.RenameCounterActivity.java

/**
 * Takes user's input name and converts it to a string, then bundles it
 * to send back to the main activity (CounterListActivity).
 * @param view/*from  w  w  w  . j  a v a2  s  . co  m*/
 */
public void renameCounter(View view) {
    EditText editText = (EditText) findViewById(R.id.enter_counter_name);
    // Gets name input from edittext & converts to string
    String counterName = editText.getText().toString();
    Intent intent = new Intent(this, CounterListActivity.class);
    Bundle bundle = new Bundle();
    bundle.putSerializable("renameCounter", counterName);
    intent.putExtras(bundle);
    startActivity(intent);
}

From source file:com.dealbreaker.cloud.backend.GCMIntentService.java

@Override
protected void onHandleIntent(Intent intent) {
    Bundle extras = intent.getExtras();//from  w  w  w .  j  a v a 2 s. c  o m
    GoogleCloudMessaging gcm = GoogleCloudMessaging.getInstance(this);
    // The getMessageType() intent parameter must be the intent you received
    // in your BroadcastReceiver.
    String messageType = gcm.getMessageType(intent);

    if (!extras.isEmpty()) { // has effect of unparcelling Bundle
        /*
         * Filter messages based on message type. Since it is likely that GCM will be
         * extended in the future with new message types, just ignore any message types you're
         * not interested in, or that you don't recognize.
         */
        if (GoogleCloudMessaging.MESSAGE_TYPE_SEND_ERROR.equals(messageType)) {
            Log.i(Consts.TAG, "onHandleIntent: message error");
        } else if (GoogleCloudMessaging.MESSAGE_TYPE_DELETED.equals(messageType)) {
            Log.i(Consts.TAG, "onHandleIntent: message deleted");
            // If it's a regular GCM message, do some work.
        } else if (GoogleCloudMessaging.MESSAGE_TYPE_MESSAGE.equals(messageType)) {
            String subId = intent.getStringExtra(GCM_KEY_SUBID);
            Log.i(Consts.TAG, "onHandleIntent: subId: " + subId);
            String[] tokens = subId.split(":");
            String typeId = tokens[1];

            // dispatch message
            if (GCM_TYPEID_QUERY.equals(typeId)) {
                Intent messageIntent = new Intent(BROADCAST_ON_MESSAGE);
                messageIntent.putExtras(intent);
                messageIntent.putExtra("token", tokens[2]);
                LocalBroadcastManager.getInstance(this).sendBroadcast(messageIntent);
            }
        }
    }
    // Release the wake lock provided by the WakefulBroadcastReceiver.
    GCMBroadcastReceiver.completeWakefulIntent(intent);
}

From source file:com.euphor.paperpad.GcmIntentService.java

private void sendNotification(String msg, String page_id) {
    mNotificationManager = (NotificationManager) this.getSystemService(Context.NOTIFICATION_SERVICE);

    Intent intent = new Intent(this, SplashActivity.class);
    Bundle bundle = new Bundle();
    bundle.putString("page_id", page_id);
    intent.putExtras(bundle);
    intent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    PendingIntent contentIntent = PendingIntent.getActivity(this, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);
    //      PendingIntent.ge
    //      PendingIntent.getActivity(this, NOTIFICATION_ID, intent, Intent.FLAG_ACTIVITY_SINGLE_TOP);
    //      PendingIntent contentIntent2 = PendingIntent.getActivity(context, requestCode, intent, flags, options)
    NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(this).setAutoCancel(false)
            .setSmallIcon(R.drawable.ic_launcher).setContentTitle(getResources().getString(R.string.app_name))
            .setStyle(new NotificationCompat.BigTextStyle().bigText(msg)).setContentText(msg);
    mBuilder.setContentIntent(contentIntent);
    mNotificationManager.notify(NOTIFICATION_ID, mBuilder.build());
}

From source file:com.parse.PushRouter.java

public synchronized boolean handlePush(String pushId, String timestamp, String channel, JSONObject data) {
    if (ParseTextUtils.isEmpty(pushId) || ParseTextUtils.isEmpty(timestamp)) {
        return false;
    }//from   www .  j  a  v  a 2  s .c  o  m

    if (!history.tryInsertPush(pushId, timestamp)) {
        return false;
    }

    // Persist the fact that we've seen this push.
    saveStateToDisk();

    Bundle extras = new Bundle();
    extras.putString(ParsePushBroadcastReceiver.KEY_PUSH_CHANNEL, channel);
    if (data == null) {
        extras.putString(ParsePushBroadcastReceiver.KEY_PUSH_DATA, "{}");
    } else {
        extras.putString(ParsePushBroadcastReceiver.KEY_PUSH_DATA, data.toString());
    }

    Intent intent = new Intent(ParsePushBroadcastReceiver.ACTION_PUSH_RECEIVE);
    intent.putExtras(extras);

    // Set the package name to keep this intent within the given package.
    Context context = Parse.getApplicationContext();
    intent.setPackage(context.getPackageName());
    context.sendBroadcast(intent);

    return true;
}