Android 客户端服务器应用程序
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/22962139/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Android client server application
提问by user2702891
I want to create an android app which should be authenticated through the server. How can I code both client side and server side to make this possible ?
我想创建一个应该通过服务器进行身份验证的 android 应用程序。如何对客户端和服务器端进行编码以使这成为可能?
On the server side what should I use to do scripting and how ?
在服务器端,我应该使用什么来编写脚本以及如何编写?
Flow should be like this:
流程应该是这样的:
- User enters it's username and password on the android app screen.
- These arg go to server where they are authenticated and response is returned to the android app.
- 用户在安卓应用屏幕上输入用户名和密码。
- 这些 arg 转到服务器,在那里对它们进行身份验证,并将响应返回给 android 应用程序。
回答by Trupti
For client side you send your request in json format(key value pair) and for server side (you can use either php or servlet ) and send the response ,in json format
对于客户端,您以 json 格式(键值对)和服务器端(您可以使用 php 或 servlet)发送您的请求并以 json 格式发送响应
Pleaes refer this link Android client server tutorial
请参考此链接 Android 客户端服务器教程
回答by Setu
You should have provided more details such as what you have tried so far so that we can direct you further but still I will try to give you basic idea
您应该提供更多详细信息,例如到目前为止您尝试过的内容,以便我们可以进一步指导您,但我仍然会尝试给您基本的想法
1. design your layout for android in xml and then define the elements in your activity class. in your case it would simply be two edittext boxed and a button then check it if works
1. 在 xml 中为 android 设计布局,然后在您的活动类中定义元素。在您的情况下,它只是两个编辑文本框和一个按钮,然后检查它是否有效
2. Which script to use for server side is upto your knowledge and proficiency and also depends upon you requirements. for basic apps you can use php. write the php script and setup your database against which you are planning to verify the args. if you are not sure thislink will take you to very simple tutorial from which you can learn or you can use other tutorials from internet.
2.服务器端使用哪种脚本取决于您的知识和熟练程度,也取决于您的要求。对于基本应用程序,您可以使用 php。编写 php 脚本并设置您计划验证参数的数据库。如果您不确定此链接将带您到非常简单的教程,您可以从中学习,或者您可以使用互联网上的其他教程。
3. Once you are done with the setup you can use different methods to see the response from such as JSONresponse or simple echo/print methods.
3. 完成设置后,您可以使用不同的方法查看响应,例如 JSONresponse 或简单的 echo/print 方法。
4. after all this you can write a class or method on you client side once again to make Httprequest using Get or post method and see the response.
4. 毕竟,您可以再次在客户端编写一个类或方法,以使用 Get 或 post 方法进行 Httprequest 并查看响应。