SearchableSpinner
SearchableSpinner copied to clipboard
Fatal Exception: java.lang.RuntimeException: Parcelable encountered IOException
Fatal Exception: java.lang.RuntimeException: Parcelable encountered IOException writing serializable object (name = com.toptoche.searchablespinnerlibrary.SearchableSpinner)
can you provide the code
ArrayAdapter<String> adapter = new ArrayAdapter<String>(getActivity(), android.R.layout.simple_spinner_item, arrayItems);
searchSpinner.setAdapter(adapter);
searchSpinner.setOnItemSelectedListener(new
AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { Log.v("item", (String) parent.getItemAtPosition(position));
}
@Override
public void onNothingSelected(AdapterView<?> parent) {
// TODO Auto-generated method stub
}
});
On Wed, Jul 19, 2017 at 2:17 PM, Karthik Ponnam [email protected] wrote:
can you provide the code
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/miteshpithadiya/SearchableSpinner/issues/55#issuecomment-316316882, or mute the thread https://github.com/notifications/unsubscribe-auth/Ac1b-2qyZPyorHpyBrKF_IULTkjxzJsPks5sPcK4gaJpZM4OZ910 .
what data type is arrayItems
?
String only.. ArrayList<String> arrayItems = new ArrayList<String>();
On Sun, Jul 23, 2017 at 3:48 PM, Karthik Ponnam [email protected] wrote:
what data type is arrayItems?
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/miteshpithadiya/SearchableSpinner/issues/55#issuecomment-317242981, or mute the thread https://github.com/notifications/unsubscribe-auth/Ac1b-67tw2-OFBP8mQ-NEwkjLzl8dNK_ks5sQx4EgaJpZM4OZ910 .
Is there any solution for this?
i was unable to replicate the error
Can you upload your sample project
Hi, I got the same issue. Please find a solution for this ASAP
Well, I solved this problem.
I don't know if it's completely correct but it works for me:
Hi, i got the same issue, when the dialog is active and my activity is: onPause() or onStop() my app crashes, another issue occurs when I double click on the spinner before the dialog opened (It was solved by creating a CustomSearchableSpinner, a solution of @ashwindmk)
Error: AndroidRuntime: FATAL EXCEPTION: main Process: com.openlab.laacademiaapp, PID: 7632 java.lang.RuntimeException: Parcelable encountered IOException writing serializable object (name = com.openlab.XXXXXXXXXX.widget.CustomSearchableSpinner)
Solution:
- Create CustomSearchableSpinner and implements Parcelable
import android.annotation.SuppressLint;
import android.content.Context;
import android.os.Handler;
import android.os.Parcel;
import android.os.Parcelable;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.view.View;
import com.toptoche.searchablespinnerlibrary.SearchableSpinner;
@SuppressLint("ParcelCreator")
public class CustomSearchableSpinner extends SearchableSpinner implements Parcelable{
public static boolean isSpinnerDialogOpen = false;
public CustomSearchableSpinner(Context context) {
super(context);
}
public CustomSearchableSpinner(Context context, AttributeSet attrs) {
super(context, attrs);
}
public CustomSearchableSpinner(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
}
@Override
public boolean onTouch(View v, MotionEvent event) {
if (event.getAction() == MotionEvent.ACTION_UP) {
if (!isSpinnerDialogOpen) {
isSpinnerDialogOpen = true;
return super.onTouch(v, event);
}
isSpinnerDialogOpen = false;
}
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
isSpinnerDialogOpen = false;
}
}, 500);
return true;
}
@Override
public int describeContents() {
return 0;
}
@Override
public void writeToParcel(Parcel dest, int flags) {
}
}
thank you
Why is this fix not merged into the library? I use SearchableSpinner (it's great!) throughout my app but sadly I get this crash report too. I am not able to reproduce it and stack traces do not show where exactly this occurrs.
@pepitofriki Your solution works great! Thanks for that. However, I am now facing another issue that I suspect is caused by @SuppressLint("ParcelCreator")
. The log reads as:
Caused by android.os.BadParcelableException
Parcelable protocol requires a Parcelable.Creator object called CREATOR on class com.xxxx.xxxx.SearchableSpinnerCustom
I tried to create the CREATOR object
, sadly I am unable to because I need a Context
object when creating my custom spinner. Any ideas on how to move from here?
Well, I solved this problem.
I don't know if it's completely correct but it works for me:
Hi, i got the same issue, when the dialog is active and my activity is: onPause() or onStop() my app crashes, another issue occurs when I double click on the spinner before the dialog opened (It was solved by creating a CustomSearchableSpinner, a solution of @ashwindmk)
Error: AndroidRuntime: FATAL EXCEPTION: main Process: com.openlab.laacademiaapp, PID: 7632 java.lang.RuntimeException: Parcelable encountered IOException writing serializable object (name = com.openlab.XXXXXXXXXX.widget.CustomSearchableSpinner)
Solution:
- Create CustomSearchableSpinner and implements Parcelable
import android.annotation.SuppressLint; import android.content.Context; import android.os.Handler; import android.os.Parcel; import android.os.Parcelable; import android.util.AttributeSet; import android.view.MotionEvent; import android.view.View; import com.toptoche.searchablespinnerlibrary.SearchableSpinner; @SuppressLint("ParcelCreator") public class CustomSearchableSpinner extends SearchableSpinner implements Parcelable{ public static boolean isSpinnerDialogOpen = false; public CustomSearchableSpinner(Context context) { super(context); } public CustomSearchableSpinner(Context context, AttributeSet attrs) { super(context, attrs); } public CustomSearchableSpinner(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); } @Override public boolean onTouch(View v, MotionEvent event) { if (event.getAction() == MotionEvent.ACTION_UP) { if (!isSpinnerDialogOpen) { isSpinnerDialogOpen = true; return super.onTouch(v, event); } isSpinnerDialogOpen = false; } new Handler().postDelayed(new Runnable() { @Override public void run() { isSpinnerDialogOpen = false; } }, 500); return true; } @Override public int describeContents() { return 0; } @Override public void writeToParcel(Parcel dest, int flags) { } }
Thanks this solved both my problems
- when onPause and onStop when the spinner is open
- double click on the spinner
This solution worked perfectly, thanks for that...