How bad is a remote service?
<p>I'm considering using a remote service in my app, but I saw in CommonsWare's answer in <a href="http://stackoverflow.com/questions/3281890/local-service-or-remote-service">this thread</a> (and other threads) that it seems remote service has many downsides/concerns like wasted CPU, memory, and battery life. This made me hesitate. So I want to run my idea by the experts here first:</p>

<p><strong>Question #1:</strong> Given my app's application (below), do you think it's a bad idea of using a remote service? Or, this is the right way to go?</p>

<p>My app has two parts, a Wi-Fi client runs on PC, a Wi-Fi server runs on Android. They transfer the app's data files located in the SD memory card back and forth through Socket. The Android app has over 48,000 lines of code, pretty big I'd say. When it starts, it starts the service automatically. The service then creates a separate thread which calls <code>ServerSocket.accept()</code> to listen in on the line. The user can press a button on the PC to initiate file transfer, even when the Android app is not running. </p>

<p>I understand services' life cycle is independent from activities'; I don't mind if the user may kill the app and service through Settings -- he killed it, he'll have to launch the app again in order to start the server. He chose to kill it, he'll start it himself.</p>

<p>But what if Android system killed the process without user's knowledge? In this case, the user doesn't know that the Wi-Fi server is dead, he'll' receive an error when he clicks the button on the PC. Therefore, I want the server keep running even when the process is killed by the system. Therefore, I think a remote service is the answer. Or, is it?</p>

<p><strong>Question #2:</strong> How to establish a simple one-way communication between the app and the remote service?</p>

<p>The only communication between the two is the app needs to know the service's status, like if it's listening on the Socket, or if it's still running, etc. If dead, the user can restart it from the app's UI. </p>

<p>I don't want to use AIDL, it seems to be an overkill; global variables don't work because they are not in the same process space; even the <code>Application</code> singleton doesn't seem to work. So right now I'm thinking about using Shared Preferences, or creating a file in the internal storage. I haven't got around to experiment with these idea, but would they work? If not, any better ideas?</p>

<p>Thank you for reading this!</p>
