Note that there are some explanatory texts on larger screens.

plurals
  1. POAndroid : getParcelableArrayList error (out of Memory)
    primarykey
    data
    text
    <p>I have a question about parcelable class (android).</p> <p>Until now, I have passed a DoubleArray between 2 Intent whithout any problem:</p> <pre><code>new double[] latLong = new double[]{loc.getLatitude(),loc.getLongitude()}; ... intent.putExtra(Site.LATTITUDE, latLong); ... startActivityForResult(intent, this.ACCESS_GOOGLE); </code></pre> <p>Today, I tried to add new data for the same activities using parcelable class. My parcelable class:</p> <pre><code>package common; import android.os.Parcel; import android.os.Parcelable; public class Site implements Parcelable { private int id; private String site_name; private int category ; private double latitude; private double longitude; /** * * @param id * @param site_name * @param category */ public Site(int id, String site_name, int category,double latitude, double lonngitude){ this.id=id; this.site_name=site_name; this.category=category; this.latitude=latitude; this.longitude=longitude; } public Site(Parcel in){ readFromParcel(in); } @Override public int describeContents() { // TODO Auto-generated method stub return 0; } @Override public void writeToParcel(Parcel dest, int flags) { dest.writeInt(this.id); dest.writeString(this.site_name); dest.writeInt(this.category); dest.writeDouble(this.latitude); dest.writeDouble(this.longitude); } /** * * @param in */ private void readFromParcel(Parcel in) { this.id = in.readInt(); this.site_name = in.readString(); this.category = in.readInt(); this.latitude = in.readInt(); this.longitude = in.readInt(); } public static final Parcelable.Creator CREATOR = new Parcelable.Creator() { public SiteGoogle createFromParcel(Parcel in) { return new Site(in); } public SiteGoogle[] newArray(int size) { return new Site[size]; } }; /* GETTER / SETTER */ public int getId() { return id; } public void setId(int id) { this.id = id; } public String getSite_name() { return site_name; } public void setSite_name(String site_name) { this.site_name = site_name; } public int getCategory() { return category; } public void setCategory(int category) { this.category = category; } public double getLatitude() { return latitude; } public void setLatitude(double latitude) { this.latitude = latitude; } public double getLongitude() { return longitude; } public void setLongitude(double longitude) { this.longitude = longitude; } } </code></pre> <p>I put some Site objects(above class) in a java ArrayList, and pass this list to my second Activity with the below code :</p> <pre><code>ArrayList&lt;Site&gt; sitesForMap = new ArrayList&lt;Site&gt;(); for(int i=0; i&lt;sites.size();i++){ SiteGoogle site = new SiteGoogle( sites.get(i).getId(), sites.get(i).getSite_name(), sites.get(i).getCat(), sites.get(i).getLatitude(), sites.get(i).getLongitude()); sitesForGoogle.add(site); } //put data in the intent intent.putExtra(Site.LATTITUDE, latLong); //first data that worked well until now intent.putParcelableArrayListExtra(Site.JSON_ARRAY, sitesForMap); //my new data startActivityForResult(intent, this.ACCESS_GOOGLE); </code></pre> <p>This code is executed perfectly(sitesForMap and latLong are not null) but in the second Activity, when I try to instance the first Double[] parameter, an error occured .</p> <pre><code>Bundle bundle = getIntent().getExtras(); double[] adresse = (double[]) bundle.getDoubleArray(Site.LATTITUDE); //worked well until today List&lt;Site&gt; sitesList = bundle.getParcelableArrayList(Site.JSON_ARRAY); </code></pre> <p>Error :</p> <pre><code>11-04 03:00:47.248: D/AndroidRuntime(642): Shutting down VM 11-04 03:00:47.248: W/dalvikvm(642): threadid=1: thread exiting with uncaught exception (group=0x4001d800) 11-04 03:00:47.350: E/AndroidRuntime(642): FATAL EXCEPTION: main 11-04 03:00:47.350: E/AndroidRuntime(642): java.lang.OutOfMemoryError 11-04 03:00:47.350: E/AndroidRuntime(642): at android.os.Parcel.readArray(Parcel.java:1476) 11-04 03:00:47.350: E/AndroidRuntime(642): at android.os.Parcel.readValue(Parcel.java:1810) 11-04 03:00:47.350: E/AndroidRuntime(642): at android.os.Parcel.readListInternal(Parcel.java:2017) 11-04 03:00:47.350: E/AndroidRuntime(642): at android.os.Parcel.readArrayList(Parcel.java:1461) 11-04 03:00:47.350: E/AndroidRuntime(642): at android.os.Parcel.readValue(Parcel.java:1792) 11-04 03:00:47.350: E/AndroidRuntime(642): at android.os.Parcel.readMapInternal(Parcel.java:2008) 11-04 03:00:47.350: E/AndroidRuntime(642): at android.os.Bundle.unparcel(Bundle.java:208) 11-04 03:00:47.350: E/AndroidRuntime(642): at android.os.Bundle.getDoubleArray(Bundle.java:1431) 11-04 03:00:47.350: E/AndroidRuntime(642): at alij.ne.jp.GoogleMapActivity.onCreate(GoogleMapActivity.java:111) 11-04 03:00:47.350: E/AndroidRuntime(642): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047) 11-04 03:00:47.350: E/AndroidRuntime(642): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627) 11-04 03:00:47.350: E/AndroidRuntime(642): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679) 11-04 03:00:47.350: E/AndroidRuntime(642): at android.app.ActivityThread.access$2300(ActivityThread.java:125) 11-04 03:00:47.350: E/AndroidRuntime(642): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033) 11-04 03:00:47.350: E/AndroidRuntime(642): at android.os.Handler.dispatchMessage(Handler.java:99) 11-04 03:00:47.350: E/AndroidRuntime(642): at android.os.Looper.loop(Looper.java:123) 11-04 03:00:47.350: E/AndroidRuntime(642): at android.app.ActivityThread.main(ActivityThread.java:4627) 11-04 03:00:47.350: E/AndroidRuntime(642): at java.lang.reflect.Method.invokeNative(Native Method) 11-04 03:00:47.350: E/AndroidRuntime(642): at java.lang.reflect.Method.invoke(Method.java:521) 11-04 03:00:47.350: E/AndroidRuntime(642): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868) 11-04 03:00:47.350: E/AndroidRuntime(642): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626) 11-04 03:00:47.350: E/AndroidRuntime(642): at dalvik.system.NativeStart.main(Native Method) 11-04 03:03:10.460: I/Process(642): Sending signal. PID: 642 SIG: 9 11-04 03:03:11.099: D/dalvikvm(652): GC_EXTERNAL_ALLOC freed 792 objects / 61464 bytes in 48ms </code></pre> <p>Someone knows what is the problem ?</p> <p>Thank you for reading my message !</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload