android - Parcelable object caching -



android - Parcelable object caching -

i'm designing app using nfc on android.when tag read, scheme sends activity tag object. tag object parcelable object. since want write later on tag according user settings, need "cache" object in way. though utilize sticky broadcast retrieve later starting lollipop, sticky broadcast deprecated. alternative save on disk, docs says, it's not thing save parcelable. guess problem can happen if cache on file object, user alter android version, tag object different , crash can happen. need memory cache, seems me there no way forcefulness android maintain memory cache, utilize sticky service, android can kill service @ time. best way in case?

when tag read, scheme sends activity tag object.

correct. and, @ point, activity, , process, in foreground. come point later.

since want write later on tag

there no "later" of significance. every millisecond wait millisecond user has chance move device out of range of tag, @ point tag object useless. if user later moves device range of tag, fresh tag object.

according user settings, need "cache" object in way.

not really. need pass tag whatever needs it. java object, , can passed parameter methods need. parcelable, , not limited intent barriers, can set tag in intent extra.

even 5 seconds problem

yes, insofar user has moved device away tag then.

because can't pass tag object "around".

yes, can, java object -- see before in answer.

i need memory cache few seconds

for 5 seconds, static info fellow member work fine.

but android doesn't provide tool maintain memory cache

static info members in android work static info members in ordinary java.

my guess concerned process beingness terminated. noted @ top of answer, @ point in time when tag, process has foreground importance. not terminated until user (e.g., press home) move app background. there chance background process terminated within 5 seconds. however, if user decided leave app, signal user not want messing nfc tag anymore.

you welcome utilize service seek increment odds process survive 5 seconds. @ point, far more user have removed device tag in 5 seconds background process have been terminated in same 5 seconds.

personally, if trying write app used nfc , reliable, write tag immediately upon receipt. delays mean may app's reliability fall, , far more due user action due process beingness terminated.

android caching parcelable

Comments

Popular posts from this blog

java - How to set log4j.defaultInitOverride property to false in jboss server 6 -

c - GStreamer 1.0 1.4.5 RTSP Example Server sends 503 Service unavailable -

Using ajax with sonata admin list view pagination -