문제

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