Example usage for android.os Parcel writeString

List of usage examples for android.os Parcel writeString

Introduction

In this page you can find the example usage for android.os Parcel writeString.

Prototype

public final void writeString(String val) 

Source Link

Document

Write a string value into the parcel at the current dataPosition(), growing dataCapacity() if needed.

Usage

From source file:Main.java

/***********************************/

public static void writeLocation(Parcel dest, Location loc) {
    dest.writeString(loc.getProvider());
    dest.writeLong(loc.getTime());//  www. j  ava 2  s .  c o m
    dest.writeDouble(loc.getLatitude());
    dest.writeDouble(loc.getLongitude());
    dest.writeDouble(loc.getAltitude());
    dest.writeFloat(loc.getAccuracy());
    dest.writeFloat(loc.getBearing());
    dest.writeFloat(loc.getSpeed());
}

From source file:Main.java

public static void writeStringToParcel(Parcel out, String str) {
    if (str != null) {
        out.writeInt(1);/*from w  ww .j a  v  a  2s.c om*/
        out.writeString(str);
    } else {
        out.writeInt(0);
    }
}

From source file:hochschuledarmstadt.photostream_tools.Fakes.java

public static Photo buildFakePhoto(int id, String filePath, String desc, boolean liked, boolean deleteable,
        int commentCount) {
    Parcel source = Parcel.obtain();
    source.writeInt(id);//from   w  w w.  j a va  2  s  .co  m
    source.writeString(filePath);
    source.writeString(desc);
    source.writeInt(liked ? 1 : 0);
    source.writeInt(deleteable ? 1 : 0);
    source.writeInt(commentCount);
    source.setDataPosition(0);
    Photo photo = Photo.CREATOR.createFromParcel(source);
    source.recycle();
    return photo;
}

From source file:Main.java

/**
 * Write a HashMap to a Parcel, class of key and value are both String
 * // w w  w. j a  v a2  s.  c o  m
 * @param map
 * @param out
 * @param flags
 */
public static void writeHashMapStringAndString(Map<String, String> map, Parcel out, int flags) {
    if (map != null) {
        out.writeInt(map.size());
        for (Entry<String, String> entry : map.entrySet()) {
            out.writeString(entry.getKey());
            out.writeString(entry.getValue());
        }
    } else {
        out.writeInt(-1);
    }
}

From source file:Main.java

public static void writeStringMap(Map<String, String> map, Parcel parcel) {
    if (map != null && map.size() > 0) {
        parcel.writeInt(map.size());/*from w  w  w.  ja  va 2 s  .  co m*/
        for (Map.Entry<String, String> entry : map.entrySet()) {
            parcel.writeString(entry.getKey());
            parcel.writeString(entry.getValue());
        }
    } else {
        parcel.writeInt(0);
    }
}

From source file:org.opendatakit.database.queries.BindArgs.java

private static void marshallObject(Parcel out, Object toMarshall) {
    if (toMarshall == null) {
        out.writeInt(0);//from  w  ww.  j a  v  a 2s  .c  o m
    } else if (toMarshall instanceof String) {
        out.writeInt(1);
        out.writeString((String) toMarshall);
    } else if (toMarshall instanceof Integer) {
        out.writeInt(2);
        out.writeInt((Integer) toMarshall);
    } else if (toMarshall instanceof Boolean) {
        if ((Boolean) toMarshall) {
            out.writeInt(3);
        } else {
            out.writeInt(4);
        }
    } else if (toMarshall instanceof Double) {
        out.writeInt(5);
        out.writeDouble((Double) toMarshall);
    } else if (toMarshall instanceof Float) {
        out.writeInt(6);
        out.writeFloat((Float) toMarshall);
    } else if (toMarshall instanceof Long) {
        out.writeInt(7);
        out.writeLong((Long) toMarshall);
    } else {
        throw new IllegalStateException("should have been prevented in constructor");
    }
}

From source file:com.clover.sdk.v3.JsonParcelHelper.java

private static void writeValue(Parcel out, int flags, Object v) {
    if (v == null || v == JSONObject.NULL) {
        out.writeInt(VAL_NULL);//w  w  w.j a v a 2s  .  c  o  m
    } else {
        Class<?> c = v.getClass();
        if (c == String.class) {
            out.writeInt(VAL_STRING);
            out.writeString((String) v);
        } else if (c == Long.class) {
            out.writeInt(VAL_LONG);
            out.writeLong((Long) v);
        } else if (c == Boolean.class) {
            out.writeInt(VAL_BOOLEAN);
            out.writeInt((Boolean) v ? 1 : 0);
        } else if (c == JSONObject.class) {
            out.writeInt(VAL_MAP);
            wrap((JSONObject) v).writeToParcel(out, flags);
        } else if (c == JSONArray.class) {
            out.writeInt(VAL_OBJECTARRAY);
            wrap((JSONArray) v).writeToParcel(out, flags);
        } else if (c == Double.class) {
            out.writeInt(VAL_DOUBLE);
            out.writeDouble((Double) v);
        } else if (c == Integer.class) {
            out.writeInt(VAL_INTEGER);
            out.writeInt((Integer) v);
        } else if (c == Float.class) {
            out.writeInt(VAL_FLOAT);
            out.writeFloat((Float) v);
        } else {
            throw new RuntimeException("Json: unable to marshal value " + v);
        }
    }
}

From source file:org.androidtransfuse.integrationTest.inject.RealParcelable.java

public void writeToParcel(Parcel parcel, int flags) {
    parcel.writeString(value);
}

From source file:com.google.samples.apps.friendlyping.model.Ping.java

@Override
public void writeToParcel(Parcel dest, int flags) {
    dest.writeString(mBody);
    dest.writeString(mFrom);
}

From source file:com.schedjoules.eventdiscovery.framework.utils.dovecote.BoxCage.java

@Override
public void writeToParcel(Parcel dest, int flags) {
    dest.writeString(mKey.name());
}