I have a model User in Rails app. It is restful with 7 actions in UsersController. When accessed using a browser,

GET http://mydomain.com/users/new 

will get a form to fill information on the new user. What should an Android app get? Should it also get a html form, fill it then send back the html? Can it get a JSON response from the new action in UsersController or maybe skip this step all together? How should this work?

有帮助吗?

解决方案

If Android app is a client of your backend service it should have its own layouts/forms etc. Then, after collecting all necessary information from user you can send a response to server using JSON, in example:

POST http://mydomain.com/users/new
{"name":"Anrnold","password":"I<3steroids"}

If you want to display custom form retrieved dinamically from server you can pass form's fields and generate form on android device programatically. But why would you want to do that?

Everyting you need to know about json is here: json.org. I also recomend Gson

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top