FileDocCategorySizeDatePackage
Presence.javaAPI DocAndroid 1.5 API5680Wed May 06 22:42:46 BST 2009com.android.im.engine

Presence

public final class Presence extends Object implements android.os.Parcelable
A Presence is an abstract presentation of the user's presence information. Note that changes made to the Presence data won't be reflected to the server until ImConnection.updateUserPresence is called. Only the logged in user can update its own presence data via ImConnection.updateUserPresence. Changes to any other contact's presence data won't be saved or sent to the server.

Fields Summary
public static final int
OFFLINE
public static final int
DO_NOT_DISTURB
public static final int
AWAY
public static final int
IDLE
public static final int
AVAILABLE
public static final int
CLIENT_TYPE_DEFAULT
public static final int
CLIENT_TYPE_MOBILE
private int
mStatus
private String
mStatusText
private byte[]
mAvatarData
private String
mAvatarType
private int
mClientType
private Map
mExtendedInfo
public static final Parcelable.Creator
CREATOR
Constructors Summary
public Presence()


      
        this(Presence.OFFLINE, null, null, null, CLIENT_TYPE_DEFAULT, null);
    
public Presence(int status, String statusText, byte[] avatarData, String avatarType, int clientType)

        this(status, statusText, avatarData, avatarType, clientType, null);
    
public Presence(int status, String statusText, byte[] avatarData, String avatarType, int clientType, Map extendedInfo)

        setStatus(status);
        mStatusText = statusText;
        setAvatar(avatarData, avatarType);
        mClientType = clientType;
        mExtendedInfo = extendedInfo;
    
public Presence(Presence p)

        this(p.mStatus, p.mStatusText, p.mAvatarData, p.mAvatarType,
                p.mClientType, p.mExtendedInfo);
    
public Presence(android.os.Parcel source)

        mStatus = source.readInt();
        mStatusText = source.readString();
        mAvatarData = source.createByteArray();
        mAvatarType = source.readString();
        mClientType = source.readInt();
        // TODO - what ClassLoader should be passed to readMap?
        // TODO - switch to Bundle
        mExtendedInfo = source.readHashMap(null);
    
Methods Summary
public intdescribeContents()

        return 0;
    
public byte[]getAvatarData()
Get avatar bitmap.

return
Avatar bitmap. Note any changes made to the bitmap itself won't be saved or sent back to the server. To change avatar call setAvatar with a new bitmap instance. FIXME: Avatar is stored as a byte array and a type string now, it will be encapsulated with an Object after we change to ContentProvider.

        if(mAvatarData == null){
            return null;
        } else {
            byte[] data = new byte[mAvatarData.length];
            System.arraycopy(mAvatarData, 0, data, 0, mAvatarData.length);
            return data;
        }
    
public java.lang.StringgetAvatarType()
Get the MIME type of avatar.

return
the MIME type of avatar.

        return mAvatarType;
    
public intgetClientType()

        return mClientType;
    
public java.util.MapgetExtendedInfo()

        return mExtendedInfo == null ? null : Collections.unmodifiableMap(mExtendedInfo);
    
public intgetStatus()

        return mStatus;
    
public java.lang.StringgetStatusText()

        return mStatusText;
    
public booleanisOnline()

        return mStatus != OFFLINE;
    
public voidsetAvatar(byte[] data, java.lang.String type)

        if(data != null) {
            mAvatarData = new byte[data.length];
            System.arraycopy(data, 0, mAvatarData, 0, data.length);
        } else {
            mAvatarData = null;
        }
        mAvatarType = type;
    
public voidsetClientType(int clientType)

        mClientType = clientType;
    
public voidsetStatus(int status)

        if (status < OFFLINE || status > AVAILABLE ) {
            throw new IllegalArgumentException("invalid presence status value");
        }
        mStatus = status;
    
public voidsetStatusText(java.lang.String statusText)

        mStatusText = statusText;
    
public voidwriteToParcel(android.os.Parcel dest, int flags)

        dest.writeInt(mStatus);
        dest.writeString(mStatusText);
        dest.writeByteArray(mAvatarData);
        dest.writeString(mAvatarType);
        dest.writeInt(mClientType);
        dest.writeMap(mExtendedInfo);