Reputation: 25
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?
Upvotes: 1
Views: 155
Reputation: 6410
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.
Upvotes: 1