2013年10月24日 星期四

Parcelable Class

package uk.co.kraya.android.demos.Parcelable;
 
import android.os.Parcel;
import android.os.Parcelable;
 
/**
 * @author Shriram Shri Shrikumar
 *
 * A basic object that can be parcelled to
 * transfer between objects
 *
 */
public class ObjectA implements Parcelable {
 
 private String strValue;
 private Integer intValue;
 
 /**
  * Standard basic constructor for non-parcel
  * object creation
  */
 public ObjectA() { ; };
 
 /**
  *
  * Constructor to use when re-constructing object
  * from a parcel
  *
  * @param in a parcel from which to read this object
  */
 public ObjectA(Parcel in) {
  readFromParcel(in);
 }
 
 /**
  * standard getter
  *
  * @return strValue
  */
 public String getStrValue() {
  return strValue;
 }
 
 /**
  * Standard setter
  *
  * @param strValue
  */
 public void setStrValue(String strValue) {
  this.strValue = strValue;
 }
 
 /**
  * standard getter
  *
  * @return
  */
 public Integer getIntValue() {
  return intValue;
 }
 
 /**
  * Standard setter
  *
  * @param intValue
  */
 public void setIntValue(Integer intValue) {
  this.intValue = intValue;
 }
 
 @Override
 public int describeContents() {
  return 0;
 }
 
 @Override
 public void writeToParcel(Parcel dest, int flags) {
 
  // We just need to write each field into the
  // parcel. When we read from parcel, they
  // will come back in the same order
  dest.writeString(strValue);
  dest.writeInt(intValue);
 }
 
 /**
  *
  * Called from the constructor to create this
  * object from a parcel.
  *
  * @param in parcel from which to re-create object
  */
 private void readFromParcel(Parcel in) {
 
  // We just need to read back each
  // field in the order that it was
  // written to the parcel
  strValue = in.readString();
  intValue = in.readInt();
 }
 
    /**
     *
     * This field is needed for Android to be able to
     * create new objects, individually or as arrays.
     *
     * This also means that you can use use the default
     * constructor to create the object and use another
     * method to hyrdate it as necessary.
     *
     * I just find it easier to use the constructor.
     * It makes sense for the way my brain thinks ;-)
     *
     */
    public static final Parcelable.Creator CREATOR =
     new Parcelable.Creator() {
            public ObjectA createFromParcel(Parcel in) {
                return new ObjectA(in);
            }
 
            public ObjectA[] newArray(int size) {
                return new ObjectA[size];
            }
        };
 
}
 
--------------------------------------------------------------------------
 
package uk.co.kraya.android.demos.Parcelable;
 
import android.os.Parcel;
import android.os.Parcelable;
 
public class ObjectB implements Parcelable {
 
 private ObjectA obj;
 private Long longVal;
 
 public ObjectB() { ; }
 
 public ObjectA getObj() {
  return obj;
 }
 
 /**
  *
  * Constructor to use when re-constructing object
  * from a parcel
  *
  * @param in a parcel from which to read this object
  */
 public ObjectB(Parcel in) {
  readFromParcel(in);
 }
 
 public void setObj(ObjectA obj) {
  this.obj = obj;
 }
 
 public Long getLongVal() {
  return longVal;
 }
 
 public void setLongVal(Long longVal) {
  this.longVal = longVal;
 }
 
 @Override
 public int describeContents() {
  return 0;
 }
 
 @Override
 public void writeToParcel(Parcel dest, int flags) {
 
  // The writeParcel method needs the flag
  // as well - but thats easy.
  dest.writeParcelable(obj, flags);
 
  // Same as in ObjectA
  dest.writeLong(longVal);
 }
 
 /**
  *
  * Called from the constructor to create this
  * object from a parcel.
  *
  * @param in parcel from which to re-create object
  */
 private void readFromParcel(Parcel in) {
 
  // readParcelable needs the ClassLoader
  // but that can be picked up from the class
  // This will solve the BadParcelableException
  // because of ClassNotFoundException
  obj = in.readParcelable(ObjectA.class.getClassLoader());
 
  // The rest is the same as in ObjectA
  longVal = in.readLong();
 }
 
    /**
     *
     * This field is needed for Android to be able to
     * create new objects, individually or as arrays.
     *
     * This also means that you can use use the default
     * constructor to create the object and use another
     * method to hyrdate it as necessary.
     *
     * I just find it easier to use the constructor.
     * It makes sense for the way my brain thinks ;-)
     *
     */
    public static final Parcelable.Creator CREATOR =
     new Parcelable.Creator() {
            public ObjectB createFromParcel(Parcel in) {
                return new ObjectB(in);
            }
 
            public ObjectB[] newArray(int size) {
                return new ObjectB[size];
            }
        };
}
 
--------------------------------------------------------------------------
[Sender]
ObjectA obj = new ObjectA();
 
// Set values etc.
 
Intent i = new Intent(this, MyActivity.class);
i.putExtra("com.package.ObjectA", obj);
 
------------------------------------------------
[Receiver] 
Bundle b = getIntent().getExtras();
ObjectA obj = b.getParcelable("com.package.ObjectA");
 
 
  
  

2013年7月25日 星期四

The Version History of Android

  • Android 1.0 (Astro)
  • Android 1.1 (Bender)
  • Android 1.5 (Cupcake)
  • Android 1.6 (Donut)
  • Android 2.1 (Éclair)
  • Android 2.2 (Froyo)
  • Android 2.3 (Gingerbread)
  • Android 3.0 (Honeycomb)
  • Android 4.0 (Ice Cream Sandwich)
  • Android 4.1 (Jelly Bean)
  • Android 4.2 (Jelly Bean MR1)
  • Android 4.3 (Jelly Bean MR2)
  • Android 4.4 (KitKat)

2013年4月30日 星期二

Error number

\alps\bionic\libc\include\netdb.h

#define    EAI_ADDRFAMILY     1    /* address family for hostname not supported */
#define    EAI_AGAIN     2    /* temporary failure in name resolution */
#define    EAI_BADFLAGS     3    /* invalid value for ai_flags */
#define    EAI_FAIL     4    /* non-recoverable failure in name resolution */
#define    EAI_FAMILY     5    /* ai_family not supported */
#define    EAI_MEMORY     6    /* memory allocation failure */
#define    EAI_NODATA     7    /* no address associated with hostname */
#define    EAI_NONAME     8    /* hostname nor servname provided, or not known */
#define    EAI_SERVICE     9    /* servname not supported for ai_socktype */
#define    EAI_SOCKTYPE    10    /* ai_socktype not supported */
#define    EAI_SYSTEM    11    /* system error returned in errno */
#define    EAI_BADHINTS    12    /* invalid value for hints */
#define    EAI_PROTOCOL    13    /* resolved protocol is unknown */
#define    EAI_OVERFLOW    14    /* argument buffer overflow */
#define    EAI_MAX        15

alps\bionic\libc\kernel\common\asm-generic\errno.h

#define EDEADLK 35
#define ENAMETOOLONG 36
#define ENOLCK 37
#define ENOSYS 38
#define ENOTEMPTY 39
#define ELOOP 40
#define EWOULDBLOCK EAGAIN
#define ENOMSG 42
#define EIDRM 43
#define ECHRNG 44
#define EL2NSYNC 45
#define EL3HLT 46
#define EL3RST 47
#define ELNRNG 48
#define EUNATCH 49
#define ENOCSI 50
#define EL2HLT 51
#define EBADE 52
#define EBADR 53
#define EXFULL 54
#define ENOANO 55
#define EBADRQC 56
#define EBADSLT 57

#define EBFONT 59
#define ENOSTR 60
#define ENODATA 61
#define ETIME 62
#define ENOSR 63
#define ENONET 64
#define ENOPKG 65
#define EREMOTE 66
#define ENOLINK 67
#define EADV 68
#define ESRMNT 69
#define ECOMM 70
#define EPROTO 71
#define EMULTIHOP 72
#define EDOTDOT 73
#define EBADMSG 74
#define EOVERFLOW 75
#define ENOTUNIQ 76
#define EBADFD 77
#define EREMCHG 78
#define ELIBACC 79
#define ELIBBAD 80
#define ELIBSCN 81
#define ELIBMAX 82
#define ELIBEXEC 83
#define EILSEQ 84
#define ERESTART 85
#define ESTRPIPE 86
#define EUSERS 87
#define ENOTSOCK 88
#define EDESTADDRREQ 89
#define EMSGSIZE 90
#define EPROTOTYPE 91
#define ENOPROTOOPT 92
#define EPROTONOSUPPORT 93
#define ESOCKTNOSUPPORT 94
#define EOPNOTSUPP 95
#define EPFNOSUPPORT 96
#define EAFNOSUPPORT 97
#define EADDRINUSE 98
#define EADDRNOTAVAIL 99
#define ENETDOWN 100
#define ENETUNREACH 101
#define ENETRESET 102
#define ECONNABORTED 103
#define ECONNRESET 104
#define ENOBUFS 105
#define EISCONN 106
#define ENOTCONN 107
#define ESHUTDOWN 108
#define ETOOMANYREFS 109
#define ETIMEDOUT 110
#define ECONNREFUSED 111
#define EHOSTDOWN 112
#define EHOSTUNREACH 113
#define EALREADY 114
#define EINPROGRESS 115
#define ESTALE 116
#define EUCLEAN 117
#define ENOTNAM 118
#define ENAVAIL 119
#define EISNAM 120
#define EREMOTEIO 121
#define EDQUOT 122

#define ENOMEDIUM 123
#define EMEDIUMTYPE 124
#define ECANCELED 125
#define ENOKEY 126
#define EKEYEXPIRED 127
#define EKEYREVOKED 128
#define EKEYREJECTED 129

#define EOWNERDEAD 130
#define ENOTRECOVERABLE 131