[英]How can i connect a google app-engine application with my android?
I've a application deployed on google app-engine..it has a registration form. 我在google app-engine上部署了一个应用程序。它有一个注册表单。 now i've made a registration form in my android application and i want that on click submit...it should be sent to the application on google app-engine and it should be persisted in the particular db...
现在我已经在我的Android应用程序中创建了一个注册表单,我想要点击提交...它应该发送到谷歌app-engine上的应用程序,它应该保存在特定的数据库中...
somebody told me to use http request and response method but i'm not aware of that thing.. can somebody please provide me with some sample code or something..... 有人告诉我使用http请求和响应方法,但我不知道那件事..有人可以请给我一些示例代码或什么.....
thanksss.... thanksss ....
You haven't specified if you're using Python or Java. 您尚未指定是使用Python还是Java。
You have to decide how you want to connect. 您必须决定如何连接。 At the simplest level you could just POST the data to Google App Engine.
在最简单的级别,您可以将数据发布到Google App Engine。 In Java you would write a servlet which handles this.
在Java中,您将编写一个处理此问题的servlet。 See Java EE tutorial .
请参阅Java EE教程 。 Alternatively you could write a web service (SOAP, RESTful) on the server which handles the data being sent from your application.
或者,您可以在服务器上编写Web服务(SOAP,RESTful),该服务处理从您的应用程序发送的数据。 Again Google this and there are countless examples.
谷歌这个和那里有无数的例子。
Assume we're going down the simplest POST route. 假设我们正在走最简单的POST路线。 So in your servlet (running on GAE) you'd have something like this:
所以在你的servlet(在GAE上运行)你会有这样的东西:
public void doPost(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException {
String value1 = request.getParameter("value1");
}
And in your android app you'd do something like: 在你的Android应用程序中你会做类似的事情:
DefaultHttpClient hc=new DefaultHttpClient();
ResponseHandler <String> res=new BasicResponseHandler();
HttpPost postMethod=new HttpPost("http://mywebsite.com/mappedurl");
List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>();
nameValuePairs.add(new BasicNameValuePair("value1", "Value my user entered"));
postMethod.setEntity(new UrlEncodedFormEntity(nameValuePairs));
String response=hc.execute(postMethod,res);
Of course value1 in the servlet would be set to "Value my user entered". 当然,servlet中的value1将设置为“Value my user entered”。
EDIT: Google have now released their Google Cloud Endpoints - this makes building RESTful services on App Engine and creating clients for Android a lot easier. 编辑:Google现已发布了他们的Google Cloud Endpoints - 这使得在App Engine上构建RESTful服务并为Android创建客户端变得更加容易。 It does tie you in to App Engine even more though - but certainly worthy of consideration.
它确实将你与App Engine联系起来 - 但是当然值得考虑。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.