コード例 #1
0
 public GlobalParcelable(Parcel in) {
   String className = in.readString();
   Log.i(
       "GlobalParcelable",
       "Constructor: " + this.getClass().getSimpleName() + "; In parcel: " + className);
   try {
     rehydrate(this, in);
   } catch (IllegalArgumentException e) {
     // TODO Auto-generated catch block
     e.printStackTrace();
   } catch (IllegalAccessException e) {
     // TODO Auto-generated catch block
     e.printStackTrace();
   }
 }
コード例 #2
0
 public GlobalParcelable createFromParcel(Parcel in) {
   // get class from first parcelled item
   Class<?> parceledClass;
   try {
     parceledClass = Class.forName(in.readString());
     Log.i("GlobalParcelable", "Creator: " + parceledClass.getSimpleName());
     // create instance of that class
     GlobalParcelable model = (GlobalParcelable) parceledClass.newInstance();
     rehydrate(model, in);
     return model;
   } catch (ClassNotFoundException e) {
     // TODO Auto-generated catch block
     e.printStackTrace();
   } catch (InstantiationException e) {
     // TODO Auto-generated catch block
     e.printStackTrace();
   } catch (IllegalAccessException e) {
     // TODO Auto-generated catch block
     e.printStackTrace();
   }
   return null;
 }