简体   繁体   English

如何使用node.js与Android通信? (MySQL的)

[英]How do I communicate with Android using node.js? (Mysql)

I am trying to communicate with Android on node server basis now. 我正在尝试与基于节点服务器的Android通信。 The database is using mysql. 该数据库正在使用mysql。 I usually do data exchange through json parsing, but I do not know how to use it. 我通常通过json解析进行数据交换,但是我不知道如何使用它。 If there is a good way, I would appreciate it if you recommend it. 如果有一个好的方法,如果您推荐它,我将不胜感激。

Normally we have to use REST API method for communicating client side application to node server. 通常,我们必须使用REST API方法将客户端应用程序传递到节点服务器。 So host your application (Node server) and make rest call by using the hosted url. 因此,托管您的应用程序(节点服务器)并使用托管的url进行调用。

Example: our node server hosted on http://example_host.com 示例:我们的节点服务器托管在http://example_host.com上

we have create a rest method for getting data from the server. 我们创建了一个rest方法来从服务器获取数据。

Method : GET , url : /user_data 方法: GET ,网址: / user_data

so make a call like : http://example_host.com/user_data 因此拨打以下电话: http : //example_host.com/user_data

it will make a response with data. 它将对数据做出响应。

For REST check out the excellent retrofit project from square 对于REST,请查看来自Square的出色改造项目

http://square.github.io/retrofit/ http://square.github.io/retrofit/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM