Example usage for android.os Bundle putSerializable

List of usage examples for android.os Bundle putSerializable

Introduction

In this page you can find the example usage for android.os Bundle putSerializable.

Prototype

@Override
public void putSerializable(@Nullable String key, @Nullable Serializable value) 

Source Link

Document

Inserts a Serializable value into the mapping of this Bundle, replacing any existing value for the given key.

Usage

From source file:ca.rmen.android.poetassistant.main.PagerAdapter.java

@Override
public Parcelable saveState() {
    Bundle bundle = new Bundle(1);
    if (mExtraTab != null)
        bundle.putSerializable(EXTRA_EXTRA_TAB, mExtraTab);
    return bundle;
}

From source file:com.iopixel.watchface.wear.app.main.grid.WatchfaceGridFragment.java

@Override
public void onSaveInstanceState(Bundle outState) {
    if (mAdapter != null) {
        if (!mAdapter.getSelection().isEmpty())
            outState.putSerializable("selection", (Serializable) mAdapter.getSelection());
        outState.putString("sendingPublicId", mSendingPublicId);
    }/*from  w  ww.  java 2 s.c  o m*/
    super.onSaveInstanceState(outState);
}

From source file:com.mifos.mifosxdroid.online.SurveyQuestionActivity.java

@Override
public void onSaveInstanceState(Bundle savedInstanceState) {
    super.onSaveInstanceState(savedInstanceState);
    savedInstanceState.putSerializable(Constants.ANSWERS, mMapScores);

}

From source file:com.homerunsb.navigationdrawertest.CompanyListFragment.java

@Override
public void onSaveInstanceState(Bundle savedInstanceState) {
    Log.i(TAG, "onSaveInstanceState()");

    // Save currently selected layout manager.
    savedInstanceState.putSerializable(KEY_LAYOUT_MANAGER, mCurrentLayoutManagerType);
    super.onSaveInstanceState(savedInstanceState);
}

From source file:com.mifos.mifosxdroid.online.SurveyQuestionViewPager.java

@Override
public void onSaveInstanceState(Bundle savedInstanceState) {
    super.onSaveInstanceState(savedInstanceState);
    savedInstanceState.putSerializable("answers", mMapScores);

}

From source file:com.amazon.adobepass.auth.AdobeAuthenticationActivity.java

/**
 * Set the corresponding extras & finish this activity
 *
 * @param throwable Contains detailed info about the cause of error.
 * @param category  Error cause category.
 *//*from w w  w  . j  a v  a2s  .  co m*/
private void setResultAndReturn(Throwable throwable, String category) {

    Intent intent = new Intent();
    Bundle bundle = new Bundle();
    bundle.putString(AuthenticationConstants.ERROR_CATEGORY, category);
    bundle.putSerializable(AuthenticationConstants.ERROR_CAUSE, throwable);
    setResult(RESULT_CANCELED, intent.putExtra(AuthenticationConstants.ERROR_BUNDLE, bundle));
    finish();
}

From source file:com.hoangsong.zumechat.gcm.MyGcmListenerService.java

/**
 * Create and show a simple notification containing the received GCM message.
 *
 *
 *///  w  w  w . j a va 2 s .com
private void sendNotification(CustomNotification customNotification) {

    String title = getString(R.string.app_name);
    long when = System.currentTimeMillis();

    NotificationCompat.Builder mBuilder = null;
    if (customNotification.getSound().equals("0") && customNotification.getVibrate().equals("0")) {
        mBuilder = new NotificationCompat.Builder(getApplicationContext()).setSmallIcon(R.mipmap.ic_launcher)
                //.setLargeIcon(BitmapFactory.decodeResource(context.getResources(), R.drawable.ic_launcher))
                .setContentTitle(title).setContentText(customNotification.getMessage())// + " " + notificationsList.get(notificationsList.size()-1).getTime())
                //.setNumber(count)
                .setWhen(when).setAutoCancel(true)
        //.setStyle(new NotificationCompat.BigTextStyle().bigText(notificationsList.get(notificationsList.size()-1).getMSG() + " " + notificationsList.get(notificationsList.size()-1).getTime()))
        //.setStyle(bigTextStyle)
        //.setTicker(message)
        ;
    } else if (customNotification.getSound().equals("1")) {
        mBuilder = new NotificationCompat.Builder(getApplicationContext()).setSmallIcon(R.mipmap.ic_launcher)
                //.setLargeIcon(BitmapFactory.decodeResource(context.getResources(), R.drawable.ic_launcher))
                .setContentTitle(title).setContentText(customNotification.getMessage())// + " " + notificationsList.get(notificationsList.size()-1).getTime())
                //.setNumber(count)
                .setWhen(when).setDefaults(Notification.DEFAULT_SOUND).setAutoCancel(true)
        //.setStyle(new NotificationCompat.BigTextStyle().bigText(notificationsList.get(notificationsList.size()-1).getMSG() + " " + notificationsList.get(notificationsList.size()-1).getTime()))
        //.setStyle(bigTextStyle)
        //.setTicker(message)
        ;
    } else if (customNotification.getVibrate().equals("1")) {
        mBuilder = new NotificationCompat.Builder(getApplicationContext()).setSmallIcon(R.mipmap.ic_launcher)
                //.setLargeIcon(BitmapFactory.decodeResource(context.getResources(), R.drawable.ic_launcher))
                .setContentTitle(title).setContentText(customNotification.getMessage())// + " " + notificationsList.get(notificationsList.size()-1).getTime())
                //.setNumber(count)
                .setWhen(when).setDefaults(Notification.DEFAULT_VIBRATE).setAutoCancel(true)
        //.setStyle(new NotificationCompat.BigTextStyle().bigText(notificationsList.get(notificationsList.size()-1).getMSG() + " " + notificationsList.get(notificationsList.size()-1).getTime()))
        //.setStyle(bigTextStyle)
        //.setTicker(message)
        ;
    } else {
        Log.e(Constants.TAG, MyGcmListenerService.class.getName() + " Exception: test all");
        mBuilder = new NotificationCompat.Builder(getApplicationContext()).setSmallIcon(R.mipmap.ic_launcher)
                //.setLargeIcon(BitmapFactory.decodeResource(context.getResources(), R.drawable.ic_launcher))
                .setContentTitle(title).setContentText(customNotification.getMessage())// + " " + notificationsList.get(notificationsList.size()-1).getTime())
                //.setNumber(count)
                .setWhen(when).setDefaults(Notification.DEFAULT_ALL).setAutoCancel(true)
        //.setStyle(new NotificationCompat.BigTextStyle().bigText(notificationsList.get(notificationsList.size()-1).getMSG() + " " + notificationsList.get(notificationsList.size()-1).getTime()))
        //.setStyle(bigTextStyle)
        //.setTicker(message)
        ;
    }

    // Creates an explicit intent for an Activity in your app
    Intent notificationIntent = new Intent(getApplicationContext(), MainActivityPhone.class);
    if (customNotification != null) {
        Bundle bundle = new Bundle();
        bundle.putSerializable("customNotification", customNotification);
        notificationIntent.putExtras(bundle);
    }

    notificationIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);

    // The stack builder object will contain an artificial back stack for the
    // started Activity.
    // This ensures that navigating backward from the Activity leads out of
    // your application to the Home screen.
    TaskStackBuilder stackBuilder = TaskStackBuilder.create(getApplicationContext());
    // Adds the back stack for the Intent (but not the Intent itself)
    stackBuilder.addParentStack(MainActivityPhone.class);
    // Adds the Intent that starts the Activity to the top of the stack
    stackBuilder.addNextIntent(notificationIntent);
    PendingIntent resultPendingIntent = stackBuilder.getPendingIntent(customNotification.getId(),
            PendingIntent.FLAG_UPDATE_CURRENT);
    mBuilder.setContentIntent(resultPendingIntent);

    NotificationManager mNotificationManager = (NotificationManager) getSystemService(
            Context.NOTIFICATION_SERVICE);
    // mId allows you to update the notification later on.
    mNotificationManager.notify(customNotification.getId(), mBuilder.build()); //Constants.NOTIFICATION_TYPE_ANNOUNCEMENT, mBuilder.build());
}

From source file:com.grass.caishi.cc.service.BaseIntentService.java

/**
 * You should not override this method for your IntentService. Instead,
 * override {@link #onHandleIntent}, which the system calls when the
 * IntentService receives a start request.
 * /*w ww  .java 2  s.co m*/
 * @see android.app.Service#onStartCommand
 */
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
    if (intent != null) {
        int ddo = intent.getIntExtra("do", 0);
        if (ddo != 0) {
            SendBean send = (SendBean) intent.getSerializableExtra("send");

            Message msg = mServiceHandler.obtainMessage();
            msg.arg1 = send.getSend_id();
            msg.what = send.getSend_id();
            Bundle b = new Bundle();
            b.putSerializable("send", send);
            msg.setData(b);
            // filelist.add(send);
            mServiceHandler.sendMessage(msg);
            intent.putExtra("do", UP_ADD);
            sendBroadcast(intent);
        }
    }

    return START_NOT_STICKY;
}

From source file:com.github.windsekirun.big5personalitydiagnostic.MainActivity.java

public void fragmentCommit(int num) {
    QuestionFragment questions = new QuestionFragment();
    Bundle bundle = new Bundle();
    bundle.putInt(QuestNum, num);// w  ww . j a va2s . co  m
    bundle.putSerializable(QuestPair, storage.getPair(num));
    bundle.putString(QuestProgress, " " + num + " / " + Questions);
    questions.setArguments(bundle);
    FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
    transaction.replace(R.id.container, questions).commit();
}