How to create a server for communication with an Android app

16,157

You didn't specify your server technology, but in principal you need to do the following:

  1. You probably want to expose them as a REST Webservice. All you need is a GET operation to basically figure out if the trial has expired or not. Since you are using Android and have gained familiarity with Java, I suggest you look at JAX-RS which is one way to implement REST in Java. If you are familiar with other language, then feel free to go for that.
  2. The simplest form of your GET URL would probably look like http://yoursite/getTrial/[beginTrialDate] where [beginTrialDate] is a date in millis since Jan 1, 1970 GMT (standard approach)
  3. On the server side, you simply took the [beginTrialDate] and check if it has exceed your trial period by comparing current time to [beginTrialDate] + [trial period]
  4. You would then return a simple JSON response containing the information whether the app has expired or not. The simplest form would be: { "hasExpired" : true/false }

  5. You would call this WebService in Android using HttpClient as you would probably know already. Check this HTTP Client Tutorial

  6. You could make the server more robust by storing the phone identifier and your GET URL change to http://yoursite/getTrial/[phoneID]. The only additional complexity is you have to look up the begin trial date by phoneID and then compare it again using the step #4

Let me know if you need more clarification and I will add it to the post

Share:
16,157
asd2005
Author by

asd2005

Updated on June 30, 2022

Comments

  • asd2005
    asd2005 almost 2 years

    I need to create a server which initially checks an Android applications trial period, so

    • on running an Android application the phones info is sent over to ther server.
    • The server stores this information.
    • Whenever the application is opened within that android phone
    • the server checks its trial period has or has not expired.

    In a way it's like an Android time bomb.

    I'm completely new to servers and really just want a basic, secure, server that simply registers a phone and compares it against a trial limit.

    Anyone have any information on how I could do this? Any code examples or tutorials are very much appreciated.

  • asd2005
    asd2005 over 12 years
    Hey, thank you very much for your reply, just so you know im very much a beginner, therefore most of what you said above im not familiar with, is there any sort of tutorial or read up to help me build knoweldge on how to carry the method provided above?? Thanks anyway
  • momo
    momo over 12 years
    I've added the links in the answer. Here are concepts that you need to get going REST-API to build the webservice, JSON as a data format, and HttpClient to call the service from Android