Forum Xamarin.Android

Data Best Practices Opinions

GlennErlerGlennErler USMember ✭✭✭

Developing an Xamarin Android app that is data centric. A set of activities that make API calls and display the response. Currently I am making the API calls from the activity. Things work but what is the best practices for the calls. When the devices rotates and the activity gets rebuilt the API is recalled. I am thinking that this is not smart. Should this go to HandlerThread, service ?? trying not to reinvent the wheel. Thx for the input.


  • JHDevJHDev USMember ✭✭

    for basic way of Android Architecture, you need to persist the data between rotation OnSaveInstanceState()
    and then retrieve again in OnCreate() (or OnActivityCreated if using Fragment)

    You can make it harder or easier by using mechanisms, it's up to you and the nature of the data.

  • GlennErlerGlennErler USMember ✭✭✭

    Thanks for the reply. I understand persisting the data on rotate. My question was that the api calls get duplicated since I currently have them in the in activity. With the api calls being replicated I can see that creating memory and threading issues. If I am wrong please set me straight. Thx G

Sign In or Register to comment.