Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create a server for communication with an Android app [closed]

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.

like image 223
asd2005 Avatar asked Aug 21 '11 03:08

asd2005


People also ask

How do Android apps communicate with server?

TCP/IP Direct Connection Here, the mobile application directly connects to the server database to get responses. To ensure confidentiality, you can use SSH or another encryption type. In this case, a mobile application uses TCP/IP sockets (or UDP if necessary) connected to the server.

Can we create a server of an Android?

Building an Android Web Server, SummarizedIf the website is relatively basic, you can use your Android device as a host and save money on powering an expensive server. Similarly, you can retake the space used by a server or a computer running as a web server. Perhaps you can use the server for a different purpose.

Do Android apps need servers?

You will need a server if you want to serve your application content to the users. It doesn't matter if your app is on IOS, Android, or Amazon Echo, you will need some sort of server space. Most of the apps developed today are Cloud Applications that need one or more external servers for the app functionality.


1 Answers

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

like image 91
momo Avatar answered Oct 17 '22 06:10

momo