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:
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.
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);
ListparamList = 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: Android, AndroidManifest, AppEngine, Java, python, upload
Comments:
<< Home
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
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.
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.
The legal difficulties of dissolving a marriage, such as property division, child custody, and other important legal issues, are handled by divorce attorneys. They try to reach just settlements between spouses or, if needed, defend your rights in court. Having an experienced attorney at your side may be quite beneficial, especially considering the emotional and legal difficulties that come with divorce. Additionally, a divorce attorney can provide knowledgeable legal advice specific to your case if you're looking for Bankruptcy Chapter 7 Lawyers Near Me . Get in touch with us now to find out more.
Subscribe to Post Comments [Atom]
<< Home
Subscribe to Posts [Atom]
Post a Comment