当前位置: 动力学知识库 > 问答 > 编程问答 >

c# - Passing complex data between activities in Android

问题描述:

I know that this question has been asked several times before and there have been a variety of answers ranging from

  1. Use the intent to pass primitive data types.
  2. Implementing the Serializable or Parseable interface and handling the serialization and de-serialization in the appropriate methods. This way, it can be passed as an parameter in the intent.
  3. Persisting data in SharedPreferences - again only supports primitive data types.
  4. Saving the object as a part of the Application object - basically a Singleton class. I don't like this method as the application might get killed and the data would not persist.

I'm writing a cross-platform application and I have ViewModels (MVVM architecture) that need to be passed around. Solution 4 works for me but I want to ensure that I will have data which is not dependent on the application lifecycle. I cannot implement Serializable (or) Parseable as the ViewModel consists of some objects that do not have serialization support (Reactive Extensions) - which rules out the other solutions.

Is there a better solution out there that I can use?

分享给朋友:
您可能感兴趣的文章:
随机阅读: