there 2 separate applications running on android device @ same time. we're responsible app1. here's happening on android device:
app1 started first, app2.
app1 display list of files containing messages.
when app2 starts, send 'connect' message app1.
app1 allow user choose file list.
when user presses 'run' button, app1 start sending messages every 3 seconds app2.
app2 send message after each 1 receives.
app1 read each message app2 sends , log file.
the final message app1 sends result in app2 sending disconnect app1.
the group responsible app2 wants use sharedpreferences accomplish this. if that, need use determine when app2 message in shared preference app1 can read it?
even if shared preferences shared between process (see @commonsware answer..) sounds poor design solution problem describes. in fact, smells horrible idea, , i'm sure won't work anyway!
saying sharedpreferences
solution communication between different apps/ process in android, ignore android api, , core components!
sharedpreferences
not designed kind of message queue between process. not close that!
android provides more elegant solutions communicating between different apps, , sharing data between them
for example:
- remote
service
binding (app1 starts service app2 can bind to) - sending broadcast 1 app when event accures , rceive other app
broadcastreceiver
- app1 can implement , expose
contentprovider
can accessed app2
and there's more!
i suggest better understand android's core components (service
, broadcastreceiver
, activity
, contentprovider
) before decision how implement apps. can't imagine way create functional application without using @ least 3 of above. can varify reading first page written in android developers getting started guide - http://developer.android.com/guide/components/fundamentals.html
links:
http://developer.android.com/reference/android/app/service.html http://developer.android.com/reference/android/content/broadcastreceiver.html http://developer.android.com/reference/android/content/contentprovider.html http://developer.android.com/guide/components/bound-services.html
Comments
Post a Comment