Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
/** 
 ** Copyright (C) SAS Institute, All rights reserved.
 ** General Public License: http://www.opensource.org/licenses/gpl-license.php
 **/

import android.os.Bundle;

import android.os.Parcelable;

public class Main {
    /** key used to extract generic String message from Bundle. */
    public static final String BUNDLE_MESSAGE = "message";

    /**
     * Concatenate two Parcelable Bundles containing String to form one Parcelable.<br>
     * The String message is stored via Bundle.putCharArray using {@link #BUNDLE_MESSAGE} as the key for the item.<br>
     *  
     * @param one       Parcelable Bundle, containing String message
     * @param another    Parcelable Bundle, containing String message
     * @return Parcelable Bundle, including Parcelable one and another.
     * @see Bundle#putCharArray(String, char[])
     * @see Bundle#getCharArray(String)
     */
    public static Parcelable assembleParcelMessage(Parcelable one, Parcelable another) {
        Bundle bundle = new Bundle();
        String message = "";
        String tmp = null;

        if (one != null) {
            tmp = ((Bundle) one).getString(BUNDLE_MESSAGE);
            if (tmp != null)
                message += tmp;
        }
        if (another != null) {
            tmp = ((Bundle) another).getString(BUNDLE_MESSAGE);
            if (tmp != null)
                message += tmp;
        }

        bundle.putString(BUNDLE_MESSAGE, message);
        bundle.setClassLoader(Bundle.class.getClassLoader());
        return bundle;
    }
}