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, 10.0.2.2, 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 10.0.2.2:8080/sendUpdate

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,
HTTP.DEFAULT_CONTENT_CHARSET);
httpost.setEntity(entity);
HttpResponse response = httpclient.execute(httpost);
Log.i(""+this, "Sent POST, got " + response.getStatusLine());

entity.consumeContent();

markUploaded(rowId);
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: , , , , ,


Comments:
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

 
When facing financial challenges, locate bankruptcy lawyers near you for expert guidance. They provide legal assistance, assess your situation, and help navigate the complex process of filing for bankruptcy.

Bankrupsy lawyers near me

 
traffic lawyer loudoun va
For expert assistance with traffic violations in Loudoun, VA, search for skilled traffic lawyers nearby. Utilize online platforms or legal directories to find attorneys with experience in Loudoun County traffic cases. Consider reviews, ratings, and recommendations to gauge their effectiveness. Local bar associations and legal aid organizations can also provide valuable information. By seeking a qualified traffic lawyer in Loudoun, VA, you ensure competent representation to navigate the legal intricacies of your case and potentially mitigate the consequences associated with the traffic offense.







 
It’s an interesting article..!! Thanks for sharing. Looks Useful. Keep Posting Top Divorce Lawyers in New York
 
New York State Divorce Process File in Supreme Court (county you live in). Agree on everything (uncontested) or disagree (contested). Serve papers, wait (no set timeframe), finalize settlement.
 
Request clarification on "Rezendi" to understand its reference to person, place, or other topic. I'm happy to assist and can provide more information if needed Domestic Violence Central Registry New Jersey.
 

Post a Comment

Subscribe to Post Comments [Atom]





<< Home

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

Subscribe to Posts [Atom]