Note that there are some explanatory texts on larger screens.

plurals
  1. POAndroid Parcelable -- RetailerOrderActivity.java return null
    primarykey
    data
    text
    <p>I have to pass one activity to another activity:</p> <p>I have SalesProduct enetity class: </p> <pre><code> public class Product implements Parcelable{ private double availableQuantity; private double price; private String productCode; private String description; private String description2; private String productGroup; private String alternateSearch; private String productTypeCode; private String nonStockItemFlag; private String salableFlag; private double weight; private double qty; private double grossValue; private double value; private ArrayList&lt;Product&gt; product; public Product() { } public Product(Parcel in) { this(); readFromParcel(in); } /* * Constructor calls read to create object */ private void readFromParcel(Parcel in) { in.readTypedList(product, Product.CREATOR); /* NULLPOINTER HERE */ } public int describeContents() { return 0; } public void writeToParcel(Parcel dest, int flags) { dest.writeList(product); } public static final Parcelable.Creator&lt;Product&gt; CREATOR = new Parcelable.Creator&lt;Product&gt;() { public Product createFromParcel(Parcel in) { Product prod = new Product(); Bundle b = in.readBundle(Product.class.getClassLoader()); prod.product = b.getParcelableArrayList("enteredProduct"); return prod; } public Product[] newArray(int size) { return new Product[size]; } }; /** * @param product */ public Product(ArrayList&lt;Product&gt; product) { this.product = product; } /** * @param availableQuantity * @param price * @param productCode * @param description * @param nonStockItemFlag * @param kitProductFlag * @param qty * @param grossValue * @param value */ public Product(double availableQuantity, double price, String productCode, String description, String nonStockItemFlag, double qty, double value) { super(); this.availableQuantity = availableQuantity; this.price = price; this.productCode = productCode; this.description = description; this.nonStockItemFlag = nonStockItemFlag; this.qty = qty; this.value = value; } public ArrayList&lt;Product&gt; getProduct() { return product; } public void setProduct(ArrayList&lt;Product&gt; product) { this.product = product; } public double getValue() { return value; } public void setValue(double value) { this.value = value; } public double getGrossValue() { return grossValue; } public void setGrossValue(double grossValue) { this.grossValue = grossValue; } public double getQty() { return qty; } public void setQty(double qty) { this.qty = qty; } public double getPrice() { return price; } public void setPrice(double price) { this.price = price; } public double getAvailableQuantity() { return availableQuantity; } public void setAvailableQuantity(double availableQuantity) { this.availableQuantity = availableQuantity; } public String getProductCode() { return productCode; } public void setProductCode(String productCode) { this.productCode = productCode; } public String getDescription() { return description; } public void setDescription(String description) { this.description = description; } public String getDescription2() { return description2; } public void setDescription2(String description2) { this.description2 = description2; } public String getProductGroup() { return productGroup; } public void setProductGroup(String productGroup) { this.productGroup = productGroup; } public String getAlternateSearch() { return alternateSearch; } public void setAlternateSearch(String alternateSearch) { this.alternateSearch = alternateSearch; } public String getProductTypeCode() { return productTypeCode; } public void setProductTypeCode(String productTypeCode) { this.productTypeCode = productTypeCode; } public String getNonStockItemFlag() { return nonStockItemFlag; } public void setNonStockItemFlag(String nonStockItemFlag) { this.nonStockItemFlag = nonStockItemFlag; } public String getSalableFlag() { return salableFlag; } public void setSalableFlag(String salableFlag) { this.salableFlag = salableFlag; } public double getWeight() { return weight; } public void setWeight(double weight) { this.weight = weight; } } </code></pre> <p>And caller Activity :</p> <pre><code> if(productMap.size() &gt;0){ ArrayList&lt;Product&gt; enteredProductList = new ArrayList&lt;Product&gt;(productMap.values()); Bundle b = new Bundle(); Product pr =new Product(enteredProductList); b.putParcelableArrayList("enteredProduct", enteredProductList); Intent showContent = new Intent(getApplicationContext(),RetailerOrderIActivity.class); showContent.putExtras(b); //Insert the Bundle object in the Intent' Extras startActivity(showContent); }else{ Toast.makeText(RetailerOrderActivity.this," You don't have invoice records" ,Toast.LENGTH_SHORT).show(); } </code></pre> <p>and receive part : </p> <pre><code> public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.order_main); Bundle b = this.getIntent().getExtras(); ArrayList&lt;Product&gt; p = b.getParcelableArrayList("enteredProduct"); System.out.println("-- RetailerOrderIActivity --" + p.size()); for (Product s : p) { System.out.println(" --Qty-" + s.getQty()); System.out.println(" --price -" + s.getPrice()); System.out.println(" --code -" + s.getProductCode()); } </code></pre> <p>This is my error part :</p> <pre><code> 09-13 16:22:43.236: ERROR/AndroidRuntime(343): FATAL EXCEPTION: main 09-13 16:22:43.236: ERROR/AndroidRuntime(343): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.xont.controller/com.xont.controller.sales.RetailerOrderIActivity}: java.lang.NullPointerException 09-13 16:22:43.236: ERROR/AndroidRuntime(343): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1647) 09-13 16:22:43.236: ERROR/AndroidRuntime(343): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663) 09-13 16:22:43.236: ERROR/AndroidRuntime(343): at android.app.ActivityThread.access$1500(ActivityThread.java:117) 09-13 16:22:43.236: ERROR/AndroidRuntime(343): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931) 09-13 16:22:43.236: ERROR/AndroidRuntime(343): at android.os.Handler.dispatchMessage(Handler.java:99) 09-13 16:22:43.236: ERROR/AndroidRuntime(343): at android.os.Looper.loop(Looper.java:123) 09-13 16:22:43.236: ERROR/AndroidRuntime(343): at android.app.ActivityThread.main(ActivityThread.java:3683) 09-13 16:22:43.236: ERROR/AndroidRuntime(343): at java.lang.reflect.Method.invokeNative(Native Method) 09-13 16:22:43.236: ERROR/AndroidRuntime(343): at java.lang.reflect.Method.invoke(Method.java:507) 09-13 16:22:43.236: ERROR/AndroidRuntime(343): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839) 09-13 16:22:43.236: ERROR/AndroidRuntime(343): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597) 09-13 16:22:43.236: ERROR/AndroidRuntime(343): at dalvik.system.NativeStart.main(Native Method) 09-13 16:22:43.236: ERROR/AndroidRuntime(343): Caused by: java.lang.NullPointerException 09-13 16:22:43.236: ERROR/AndroidRuntime(343): at com.xont.entity.Product$1.createFromParcel(Product.java:94) 09-13 16:22:43.236: ERROR/AndroidRuntime(343): at com.xont.entity.Product$1.createFromParcel(Product.java:1) 09-13 16:22:43.236: ERROR/AndroidRuntime(343): at android.os.Parcel.readParcelable(Parcel.java:1981) 09-13 16:22:43.236: ERROR/AndroidRuntime(343): at android.os.Parcel.readValue(Parcel.java:1846) 09-13 16:22:43.236: ERROR/AndroidRuntime(343): at android.os.Parcel.readListInternal(Parcel.java:2092) 09-13 16:22:43.236: ERROR/AndroidRuntime(343): at android.os.Parcel.readArrayList(Parcel.java:1536) 09-13 16:22:43.236: ERROR/AndroidRuntime(343): at android.os.Parcel.readValue(Parcel.java:1867) 09-13 16:22:43.236: ERROR/AndroidRuntime(343): at android.os.Parcel.readMapInternal(Parcel.java:2083) 09-13 16:22:43.236: ERROR/AndroidRuntime(343): at android.os.Bundle.unparcel(Bundle.java:208) 09-13 16:22:43.236: ERROR/AndroidRuntime(343): at android.os.Bundle.getParcelableArrayList(Bundle.java:1144) 09-13 16:22:43.236: ERROR/AndroidRuntime(343): at com.xont.controller.sales.RetailerOrderIActivity.onCreate(RetailerOrderIActivity.java:18) 09-13 16:22:43.236: ERROR/AndroidRuntime(343): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047) 09-13 16:22:43.236: ERROR/AndroidRuntime(343): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611) </code></pre> <p>Please help me..its return null ... where is wrong ?please advice me on this?</p> <p>Thanks in advance</p>
    singulars
    1. This table or related slice is empty.
    plurals
    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