简体   繁体   English

我必须怎么做才能从Android应用程序上的服务器接收JSON数据

[英]What must I do to receive JSON data from a server on an android app

I have PHP script on the server side which executes the SQL query and produces a JSON string from it. 我在服务器端有PHP脚本,该脚本执行SQL查询并从中生成JSON字符串。 But how do I get that code to execute to then retrieve and decode the JSON on the Android app? 但是,如何获取要执行的代码,然后在Android应用上检索和解码JSON

I am quite new to android so as much help would be very appreciated. 我对android很陌生,因此非常感谢您的帮助。

I can't write you the whole tutorial but i can give you a to-do list which you can check your progress. 我无法为您写完整的教程,但是我可以给您一个待办事项清单,您可以检查进度。

  1. Your application to generate JSON script in txt, or real time response. 您的应用程序以txt或实时响应的形式生成JSON脚本。

  2. Setup your backend server(you have sql server already and also PHP, so i guess you have set it up already, probably WAMP or similar), which is the endpoint/url path to generate the response required, in this case your JSON response. 设置您的后端服务器(您已经有sql server,也有PHP,所以我想您已经设置了它,可能是WAMP或类似的东西),这是生成所需响应的端点/ URL路径,在这种情况下为JSON响应。

  3. Check the API is working or not by using "advanced rest client" or simple type your endpoint in browser, if you can get the correct response from it, the API is working as expected. 通过使用“高级其余客户端”或在浏览器中简单键入端点来检查API是否正常工作,如果可以从中获得正确的响应,则表明API是否按预期工作。

  4. Created your android app, with simple HTTP request/response, send a HTTP request to the url/path you setup, see if you can get the JSON response or not. 使用简单的HTTP请求/响应创建了您的android应用,将HTTP请求发送到您设置的url /路径,看看是否可以获得JSON响应。

Please comment here if you need further details, this is relatively easy and should be able to finished in 1 day for beginner. 如果您需要更多详细信息,请在这里发表评论,这相对容易,对于初学者来说应该可以在1天之内完成。

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

相关问题 服务器从android应用接收空的JSON字符串数组 - Server Receive empty JSON string array From android app Android 应用程序 - 从服务器发送和接收数据的问题 - Android app - problem with send and receive data from server 如何从服务器到Android接收数据 - how to receive data from server to android 如何从android应用发送json数据并在jersey中运行的其余Web服务中接收它? - How to send json data from android app and receive it in rest web service running in jersey? 我需要在服务器上做什么才能与Android应用程序通信? - What to I need to do to on my server to communicate with an Android app? 如何使用JSON从远程数据库检索数据并显示在android应用程序xml文件中? - How do i retrieve the data using JSON from the Remote Database and display in my android app xml file? 如果Android杀了我的应用程序并且我从设置中执行强制关闭,我会收到GCM消息吗? - Will I receive GCM messages if Android kill my app and if I do a Force Close from the settings? 如何从Java服务器使用XMLHttpRequest接收压缩的JSON数据 - How to receive compressed JSON data using XMLHttpRequest from a java server 从Android中的地图应用接收地址的广播动作是什么 - What would the broadcast action to receive address from maps app in android 从eclipse-Android连接服务器该怎么办? - What should I do to connect to Server from eclipse - Android?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM