SearchableSpinner icon indicating copy to clipboard operation
SearchableSpinner copied to clipboard

App crashes when the spinner search dialog is open and the activity onPuase()/onStop() is called

Open MrHamidKhan opened this issue 8 years ago • 5 comments

In my case, I just open Overview Screen ("Recent Apps") while I have the SearchableSpinner dialog box open in an activity. As soon as the OnPause() is called, the app crashes. 100% reproducible.

Exception logcat: java.lang.RuntimeException: Parcelable encountered IOException writing serializable object (name = com.toptoche.searchablespinnerlibrary.SearchableSpinner)

MrHamidKhan avatar Dec 12 '16 13:12 MrHamidKhan

Same issue here. Did you find a solution?

rishabhsri20 avatar Dec 15 '16 06:12 rishabhsri20

Get the code SearchableSpinner file locally to your project, and add "implements Serializable" to the class definition.. I think that should solve it. I didn't check it yet. Waiting for a more accurate answer from the developer.

MrHamidKhan avatar Dec 15 '16 06:12 MrHamidKhan

Finally figured out a solution.

Going through the SearchableSpinner library, the dialog (_searchableListDialog) is created with a tag "TAG".. so, to solve the problem, in the activity's or fragment's onPause() just find the dialog with that tag and remove it using fragment manager.

The following function does the same. Just use it in your onPause() or anytime before onSavedInstanceState().

public void removeSearchableDialog() {
        Fragment searchableSpinnerDialog = getFragmentManager().findFragmentByTag("TAG");

        if (searchableSpinnerDialog != null && searchableSpinnerDialog.isAdded()) {
            getFragmentManager().beginTransaction().remove(searchableSpinnerDialog).commit();
        }
    }

PS: You got to do the reverse of it, if you want it back on your activity's or fragment's onResume().

MrHamidKhan avatar Dec 23 '16 15:12 MrHamidKhan

Hi Mitesh, I am facing the same issue in my App, Can u please add this solution if it works, in the next update, It would be very helpful because I have been using your library on the production App. Thanks

Ashish0988 avatar Jan 23 '17 07:01 Ashish0988

Refer this : https://github.com/AnithJo/SearchableSpinner

AnithJo avatar Mar 09 '18 07:03 AnithJo