0

我正在开发一个家庭自动化系统,我的 android 应用程序可以使用蓝牙打开和关闭灯,我想添加另一个从网页控制设备的功能。

谁能告诉我最简单的方法是什么,我知道 GCM(Google Cloud Messaging)是最好的解决方案,但还有其他更好或更简单的方法吗?

如果有人有一些工作代码,请与我分享;我想尽快完成这个项目

4

1 回答 1

0

If you have a backend built using PHP, Rails etc you can have API's that the app can call and check for instructions. However, this has the side effect of draining he battery due to continous polling.

If you don't wanna go the "polling the server periodically" way, you can use GCM as you mentioned.

You can send data using the JSON data format. This is easily the lighest and most versatile data format used by many web and android apps and has tremendous support from third party libraries as well.

Here are some tutorials for this:

http://developer.android.com/guide/google/gcm/demo.html

http://android.amolgupta.in/2012/07/google-cloud-messaging-gcm-tutorial.html

http://www.londatiga.net/featured-articles/how-to-send-message-to-google-cloud-messaging-gcm-server-using-json-and-php/

http://fundroiding.wordpress.com/2012/06/29/google-cloud-messaging-for-android-gcm-simple-tutorial/

http://androidjayavelu.blogspot.in/2012/07/google-cloud-messaging-gcm-tutorial_27.html

于 2012-11-03T07:47:36.210 回答