简体   繁体   中英

android development architecture (android vs java web app)

I'm a Java webapp developer who is new to Android development. In general, my web apps have a DB layer, a POJO layer, a UI layer, and a BusinessProcess layer. In my research of Android applications, I have not come across the BusinessProcess layer. I have implemented my app with one, but I find it clunky, having to pass in either the DB object or the ApplicationContext in order to access the DB but there are times when I find that I have redundant code. I'd rather have an extra layer handle the logic than copy-and-paste it three times in an Activity. In general, what do other people do? What do you recommend?

A service http://developer.android.com/guide/components/services.html such as IntentService http://developer.android.com/reference/android/app/IntentService.html would act as your business process layer, yet most mobile applications are not generally thick clients but thin clients than user a remote web server as the content and business process authority, at which point the service (or sometimes ContentProvider http://developer.android.com/guide/topics/providers/content-providers.html ) would interact with the remote server and cache results in a database.

See http://mobile.tutsplus.com/tutorials/android/android-fundamentals-intentservice-basics/

Edit: A bound service would suit your purposes well, depending if you need the work done synchronously instead of asynchronously.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM