client -server app

Hello,

I’m new to android,been learning for one month or so.
I want to make an app,which will access a web service,
or for a start,just a database.

i have some questions:

  1. Are there any good FREE hosting services for android apps?
    I rather it would be such a service you can host a web service and a database on.

How did you go about making your app with a database,or service?
which hosting service did you use?

2.Is google app engine any good?
3.Can i have some references to tutorials about making such an app,
i’ve searched,but i can’t really find anything useful (or maybe i don’t know what i’m looking for).

Thank you very much in advance :slight_smile:

I would recommend looking for a service for hosting php+mysql. You can find very cheap options, not sure if you’ll find any free ones though.

You can install something such as WAMP on your own pc for testing which basically installs Apache Web Server + Mysql + PHP + some management utilities.

You will need to then learn some php and database coding so you can make pages to accept or send responses to your app.

@hyarion: howzit!

@boja: Depends what you want the database for.

My app uses Google AppEngine (Python) and JSON to transfer the data.

You should provide a little more information on what you want to do!

Thanks for the quick replies :slight_smile:

Basically the app is:

1.the user posts something
2. the post is saved in the database
3.people can vote about the post -> update database

and again,if anyone could direct me to some tutorials on the matter i would be grateful.

I’m using google appengine as well (java webservice serving JSON responses). Not sure how it compares to other hosting, but I had no idea about hosting when I was looking and it seemed pretty easy to set up. So far it’s been free and stayed below their quotas but it wouldn’t take too much volume to go above the free quotas and have to pay a little.

I can’t remember what tutorials I found when I set this up. I will look around and see if I can find them.

Ok, so this is spectacularly simple.

You need to accept a set of URL’s that do something like this:

  1. login / authenticate user (so you can ban spammers). Might need to get the phone’s unique identifier too to prevent idiots just making another username
  2. get_list_of_posts. This needs to return the human readable titles and also a key to be able to get the full details of an individual post
  3. get_full_details_of_post (needs key from (2)
  4. update_post (needs key from (2)

Then you probably also want to build an admin interface for yourself to provide more control.

Pick a language to do the interface in… Python,Ruby,PHP,ASP,Perl/JSP/whatever you know.
Pick a database… MySQL/etc

Things to worry about: if you have 1000 queries/sec coming into the database from users… uhh… if that is the case, you probably figured out how to make money… lots of money and can PAY SOMEONE WHO ACTUALLY KNOWS WTF THEY ARE DOING… to do it properly (this is my plan for when I have thousands of simultaneous users!!!) :slight_smile:

Then figure out how to transfer the data from server to client. JSON is nice and simple and human readable too. More than one of us has used it.

Last step on your road to riches: Post here!!!

Thank you all for your replies.
I’ll get to it soon,and post progress and probably more questions!

Thanks alot :slight_smile:

Hi ,

I don’t have much experience on this side but i once saw these tutorials that helped me to sort the simple problems i wanted to solve then. These tutorials, with source code provided, can be found on the links i have indicated…

  1. This tutorial from IBM describes how to use different data formats within Android applications(XML, JSON, Google Protocol buffers) and generally using internet data in android applications. http://www.ibm.com/developerworks/xml/library/x-dataAndroid/

  2. For database using sqlite you might find this helpful http://www.androidhive.info/2011/11/android-sqlite-database-tutorial/

  3. For parsing JSON, this one was quite helpful atleast for me to understand. http://www.androidhive.info/2012/01/android-json-parsing-tutorial/

  4. I saw this nice video tutorial on youtube of android app engine integration from the google guys. I bet it will be helpful tutorial on Google App Engine integration http://www.javacodegeeks.com/2011/06/android-app-engine-integration.html

  5. Finally, this tutorial describes how to design a login registration and also covers how to build simple API using PHP and MySQL. http://www.androidhive.info/2012/01/android-login-and-registration-with-php-mysql-and-sqlite/

Maybe these tutorials woun’t be quite helpful for established developers but for sure they are going to help beginners.

Thanks

There might be some frameworks that will do the trick.
Out of the top of my head I would suggest to look at the amazon services, they offer cloud services. They might have a framework ready to use.

If not and you want to do it yourself, I would suggest you to look into asp.net to develop a webservice (there is a free visual studio version). You then use the WSDL standard. If you want to use php, lookup how to implement a WSDL webservice in php. Theres enough information and tutorials online on this subject, just use Google with the keywords WSDL, cloud service or webservice.

There are a whole bunch of Rest Client’s available in Java online. eg:

This one

If you were running Google AppEngine, your Python code to output JSON could look like this:


import webapp2, json
class getJSON_Key(webapp2.RequestHandler):
    def get(self):
        output = { 'key' : 'Hello World', }
        self.response.out.write(json.dumps(out))

Now, to query the server and receive the response:


String jsonResponse;
RestClient client = new RestClient(baseurlString);
try {
  client.Execute(RequestMethod.GET);
} catch (Exception e) {
  e.printStackTrace();
}
jsonResponse= client.getResponse();

And to parse JSON for our variable called ‘key’, you could do the following:

public String parseJSONforKey(String jsonResponse) {
  JSONObject json;
  String result = "";
  try {
      json = new JSONObject(jsonResponse);
      result = json.getString("key");
  } catch (JSONException e) {
      e.printStackTrace();
  }
  return result;
}

There are a couple of components to get your head around:

  • the server output
  • a service or async task to download the data in the background
  • parsing the result

Tackle each one in turn and it will be easy!

Again,thank you all :slight_smile:

Quick question: what API do you think i should develop for?

2.3.x?
3.x?
or 4.x?

Cause 2.3 seems kinda old,but i get the sense that a lot of users don’t upgrade as soon as an upgrade is out,and stick to what’s comfortable(like me:) )

Most users are on 2.x, so you should support 2.1 minimum. You can target the latest 4.x 15 is the latest I believe. Make sure to check if you are using functions from later sdk because that will give an error when called in runtime. For example setAlpha will fail on versions before 11, so you need to check the version at runtime to make your code backwards compatible.

In short, set target sdk to the latest, set minimum sdk to 2.1 and test on all platforms with the emulator.
[hr]
Ow and for a few things google has a compatiblilty library. You can include that in your project to get access to some stuff thats been introduced in later versions. I believe its in your extra folder in the sdk folder.

awkward question:

i can’t seem to sign up for C2DM - https://developers.google.com/android/c2dm/signup
I accept the terms,but then,when the form shows up,i can’t fill in the details.It’s like a picture,nothing is responding.
Tried different comps,browsers. Any advice or sanity check?
I would have skip that step,but it’s an important part in the App Engine framework.

Thanks.

Ask yourself if you really need C2DM … or can you get something up and running as a test platform without it and figure it out later.

You have a lot of new technology to play with. Servers, communication, databases, Android… maybe get some of that done first ?