So guys here is my case
Im creating a Music player app with playlist.
Im in the process of designing the fragment that will control the Music and i have 3 cases that i want TO discuss with you guys about how TO handle the audio playback and the display of the playlist.
I have a listfragment which has a list that works as a playlist, 3 buttons that change the playlist and a background service that is displaying the audio.so what i want TO discuss is this:
1) sending the data To the service.
2) sending data from the service To the fragment.
3) handling displayed data on the fragment when the fragment is paused / killed.
The data im talking about could be:
A) a list with song names and ids
B)the current song name theme name album image
C)the position int of the playlist.
For all the above i want To ask some questions about how TO handle each case.
My initial plan was To use public list accessible from both fragment and service but that might not BE a good idea because i have read that the garbage collector might destroy those lists.is that true?
I have read most of the XAmarin guides com many articles and from what i have read i have those options:
i) use public classes.
ii)use intent TO send data.
iii)use sharedpreferences or sql TO retrieve data.
iv)use broadcast reciever TO send data.
The option i is what im doing now.
For the case 1 i need TO send TO the service all the data.should i use intent? Should i keep using public lists or should i retrieve the data from sql or sharedpref?what is the best approach.
About the case 2 i think the best approach is broadcastrec. Because IT will send the data and If the fragment is not shown the data will BE ignored which is OK.
About case 3, the fragment might get distroyed and need TO BE created again so i need TO create the list,get the current category and list position.for those data im thinking to reproduce them on oncreateview and on onupdate by extracting them from sharedpref except the list that will get IT from sql.
For all those cases which is the best approach, please advice, thanks.