Distributed Application in Android
Asked Answered
L

2

6

I am trying to partition an android application in order to execute it partially in on the phone, and partially on the server (the server could have an emulator run in it). I have read that RMIs are not supported by android. I am thinking of doing this like a client-server architecture, where an emulator is run in eclipse. So is it feasible to achieve do this project? any ideas are highly appreciated.

thank you.

Luminance answered 4/5, 2011 at 21:33 Comment(0)
R
0

It's quite normal that Android devices talk to servers where data is stored and business logic is executed. Mobile devices usually talk to servers via web services, the most popular seems to be REST+JSON. Implementations:

  1. Server. Code needs to talk to database, execute business logic and communicate data to devices via REST+JSON. Implementation depends on your knowledge of languages/platforms.

  2. Android calls REST services and processes returned JSON data. Use HttpClient to make REST calls and GSON to parse returned JSON data.

Royal answered 4/5, 2011 at 21:53 Comment(3)
the methods executed at the server may be different every time (according to the decision made at the phone side whether to offload or not, and what to offload exactly). Is this feasible at all? This would create many many scenarios for the possible way of communication between the server and the phone (not a regular static client-server architecture) so i don't know if i can do that or not. Any advice? thank you a lotLuminance
web services resemble normal method calls: you choose a method to call, pass in some parameters (objects) and then get the reply (one object)Royal
A simple example of REST on server (this is how java server code for REST looks): docs.jboss.org/resteasy/docs/2.0.0.GA/userguide/html_single/…Royal
A
0

You would have much more success with using a standard server to offload the heavy lifting to. My experience with the Android emulator is that it processes tasks more than twice as slowly as tasks take on my phone, suggesting that you will actually have no gain in productivity by offloading the work to an emulator.

If you use a standard Java server doing the work, you will find it delivers far more gains.

Amphoteric answered 4/5, 2011 at 21:54 Comment(3)
yes I guess will use a regular java server. The challenge of my project is that I am trying to decide (based on the available resources such as the type of device and network bandwidth etc..) whether to execute a method locally or on the server (since if you decide to offload all time, this might require more power consumption at the android phone). To do this, I should understand the dependencies of application, and partition it. Do you advice me to do the partitioning at the level of classes or functions? Thank you for your help.Luminance
Yes, create a new Java Project in Eclipse and put all of your expensive methods in there. Then, you can include that Project in your Android Project and in your new Server Project. That will allow you to keep a centralized set of classes and methods to keep your Android and Server code synchronized.Amphoteric
this method seems interesting, i will try it. Thank you so muchLuminance

© 2022 - 2024 — McMap. All rights reserved.