如何将Google App Engine用作Android应用程式的后端资料库 [英] How to use the Google App Engine as a backend database for Android applications
问题描述
我实际上是一个初学者在android和需要很多帮助。我已经做了一个应用程序与嵌入式数据库,现在想把它放到一些动态的位置。有简单的数据形式(一些地址和分支信息等)。我实际上不知道如何使用动态位置的动态服务器。
我该如何做?请逐步指导我
我浏览了一些字词,例如写服务,关闭/打开后端<强>等。请指导我。另一个问题,我有:我需要某种注册,api键或任何其他的东西。我只是为eclipse添加了google插件,我可以创建与Android应用程序连接的App引擎
p>是的,你需要一把钥匙。查看此 http://developer.android.com/google/gcm/gs.html
首先,我们需要为您设置的示例( App engine connected with Android App )using)使用
com.google.android.gcm.server.Sender辅助类
同样,该助手类是第4步,如何使用它是在编写服务器端应用程序服务器端应用程序
当然,您想要保留或查找数据。可以在用于发送/接收消息的任何类中使用(当然使用上面的Sender辅助类)
然后最简单也许最好的方法对于AppEngine,如果你使用Java就是使用Objectify。相信我或google它看到它是多么好。 https://code.google.com/p/objectify-appengine/ p>
Objectify的文档真的很好,我第一次没有任何麻烦。
例如:
@Entity
class Car {
@Id String vin; //可以是长,长或字符串
字符串颜色;
}
ofy()。save()。entity(new Car(123123,red))。
Car c = ofy()。load()。type(Car.class).id(123123)。get();
ofy()。delete()。entity(c);
我认为你很好。
总结:
-
YourMessageClass(在Appengine上)
- 使用com.google.android.gcm.server.Sender发送/接收数据
- 使用Objectify来保存数据。
下一个问题是你把YourMessageClass放在哪里。它将在处理短期请求的Servlet中? ( https://developers.google.com/appengine/docs/java/runtime# Requests_and_Servlets )它会在一个长期运行的后端吗? ( https://developers.google.com/appengine/docs/java/backends/ ),但这超出了本文的讨论范围之内。
I'm actually a beginner in android and needs a lot of help. I have made an app with embedded database and now want to put it onto some dynamic location. Have simple form of data (some addresses and branch information etc). I actually have no idea about how to use a dynamic server placed on dynamic location.
How can I do this? Please guide me stepwise
I browsed and found some terms like "write Service", "Close/open back-ends" etc. Kindly do guide me. Another question that I have is: do I need some kind of registration, api-key or any other thing. I just added the "google plugins" for eclipse and I can create App engine connected with Android App
Yes you do need a key. Look at this http://developer.android.com/google/gcm/gs.html
First, we need to send data to/from the client for the example you set up (App engine connected with Android App) using
com.google.android.gcm.server.Sender helper class
Again, that helper class is step #4 and how to use it is in Writing the Server-side Application Server-side Application
Naturally then you want to persist or look up data. You can do that in the whatever class is used to send/receive messages (which of course uses the Sender helper class above)
Then the easiest and maybe best way for AppEngine if you are using Java is to use Objectify. Trust me or google it to see how good it is. https://code.google.com/p/objectify-appengine/
The docs for Objectify are really good and I didn't really have any trouble the first times.
Their simple example is:
@Entity
class Car {
@Id String vin; // Can be Long, long, or String
String color;
}
ofy().save().entity(new Car("123123", "red")).now();
Car c = ofy().load().type(Car.class).id("123123").get();
ofy().delete().entity(c);
I think you are good to go.
Summary:
YourMessageClass (on Appengine)
-- uses com.google.android.gcm.server.Sender to send/recieve data
-- uses Objectify to persist data.
The next question is where are you putting YourMessageClass. Will it be in a Servlet that is handling a short-lived request? (https://developers.google.com/appengine/docs/java/runtime#Requests_and_Servlets) Will it be in a long-running backend? (https://developers.google.com/appengine/docs/java/backends/) but that is beyond the scope of this discussion.
这篇关于如何将Google App Engine用作Android应用程式的后端资料库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!