I'm new to fragments.I am trying to call search API in my fragment using AsyncTask. Json Parsing is done in MainActivity, by the way I'm not in my main activity when I use this fragment, it's connected to another activity. It works, but I'm having trouble passing the parsed info that I stored into a bundle to a new fragment. To be specific it crashes the moment I try to open a new fragment. I have the parsed information and I've set the arguments for my fragment, it's just the moment I use .commit() it crashes.
It would be great if you could post the piece of your code so we can check what is the issue.
Although I have deduced from your explanation that you might be saving the information in doInBackground
which runs on the background thread. Instead, you could pass that info to the onPostExecute
and save it into SharedPreferences
since onPostExecute
runs on the UI thread.
Let me know if this works.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.