realm - Can not convert RealmList<T> to JSONObject string android -


i have 2 activity, want send data activity 1 activity 2 when clicking list item. on clicking can data mapped listitem, data kind of realmlist type. used gson library convert model json string. can achieve if data type of list using realmlist. when try achieve following application gets freezed.

this filter model :

    filter filter = new filter();     filter.settitle("");     filter.setid("");     filter.setcode(""); 

realmlist :

    realmlist<filter> list = new realmlist<filter>(); 

i tried convert above list jsonobject string follows :

 new gson().tojson(filter)) 

above live giving me following error :

 pid: 12959 reason: input dispatching timed out (waiting send non-key event because touched window has not finished processing input events delivered on 500.0ms ago.  wait queue length: 4.  wait queue head age: 5647.8ms.)                                             load: 10.67 / 9.63 / 9.38                                             cpu usage 1103ms -6084ms ago:                                               101% 12959/com.anubavam.creatrix: 98% user + 3.4% kernel / faults: 6335 minor 15 major                                               44% 832/system_server: 25% user + 18% kernel / faults: 8128 minor 104 major                                               10% 1623/com.android.phone: 5.5% user + 5.4% kernel / faults: 4275 minor 57 major                                               3.6% 4304/android.process.media: 1.7% user + 1.9% kernel / faults: 4931 minor 73 major                                               0% 286/debuggerd: 0% user + 0% kernel / faults: 3205 minor 38 major                                               5.8% 91/kswapd0: 0% user + 5.8% kernel                                               5.8% 1272/com.android.systemui: 3.8% user + 1.9% kernel / faults: 2852 minor 39 major                                               4.5% 302/zygote: 3% user + 1.5% kernel / faults: 11239 minor                                               3.4% 1580/com.motorola.process.system: 2.3% user + 1.1% kernel / faults: 1881 minor 1 major                                               3.3% 153/mmcqd/0: 0% user + 3.3% kernel 

note list , arraylist not give me error, working file.but realmlist problem. tries following line also, no use.

    list<filter> list = new realmlist<filter>(); 

can 1 have work around this.

as of now, realm objects not serializable, see this answer. means cannot pass object through intent other activity or converting json using gson library.

however, there 2 ways using can have model in second activity.

  1. pass primary key of model through intent , in second
    activity fetch model again db using key.
  2. you can parceler library serializing object , passing second activity. check this answer using parceler.

Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

ios - Change Storyboard View using Seague -