Friday, May 22, 2009


Well, that was easy.

So I created a new Google AppEngine project in Python: a very simple one, which just takes a particular HTTP POST request, stores its values to the datastore, and displays them on-screen. Then I added a "upload" function to my Android's DbHelper class, and connected the latter to the former.

I expected the debugging to be messy and lengthy. But whaddaya know? All I had to do was add the INTERNET permission to my AndroidManifest.xml, and correct the URL that I was pointing to (I'm running the AppEngine app locally; the Android emulator has a special IP address,, to connect to its host machine) and poof, amazingly, It Just Worked.

Here's the Android code, in case anyone needs an example:

public boolean uploadNote(long rowId, String location, String title, String comments, String picturePath) {
try {

DefaultHttpClient httpclient = new DefaultHttpClient();
httpclient.getParams().setParameter("http.useragent", Util.AppName);
HttpPost httpost = new HttpPost(Util.wtwSite); // temporarily

Log.i(""+this, "Preparing to post to "+Util.wtwSite);

List paramList = new LinkedList();
paramList.add(new BasicNameValuePair("email", Util.GetUserEmail()));
paramList.add(new BasicNameValuePair("title", title));
paramList.add(new BasicNameValuePair("location", location));
paramList.add(new BasicNameValuePair("comments", comments));
paramList.add(new BasicNameValuePair("image", picturePath));
UrlEncodedFormEntity entity = new UrlEncodedFormEntity(paramList,
HttpResponse response = httpclient.execute(httpost);
Log.i(""+this, "Sent POST, got " + response.getStatusLine());


return true;
catch (IOException ex)
Log.e(""+this, "Could not upload note with row "+rowId+ " due to "+ex, ex);
return false;

I'm not even going to bother posting the server code, as it's so simple; 70 lines of Python, and 30 lines of HTML.

You'll note at the moment I just upload a picture URL, rather than actual data, but I'm going to move to doing the latter eventually.

Labels: , , , , ,

There is a lot to tell you, for example, that there is a essayshark scam that do any writing and homework that can also be ordered, but overall very good, then you found me because this is good advice for an assistant
here is a lot to tell you, for example, that there is a Webdesigners LLC that do any thinks abots to make best web designs in All over Us, Florida.
I am glad to see nice post. It is very informative and valuable post. Your insights are truly inspired. Thanks for sharing. Prince William Traffic Lawyer


Post a Comment

Subscribe to Post Comments [Atom]

<< Home

This page is powered by Blogger. Isn't yours?

Subscribe to Posts [Atom]