相关疑难解决方法(0)

需要实现Virgil Dobjanschi REST实现模式的示例Android REST Client项目

我想在Android手机上构建一个REST客户端.

REST服务器公开了几个资源,例如(GET)

http://foo.bar/customer      List of all customer
http://foo.bar/customer/4711    The customer with id 4711
http://foo.bar/customer/vip     List of all VIP customer

http://foo.bar/company           List of all companys
http://foo.bar/company/4711     The company with the ID 4711
http://foo.bar/company/vip      List of all VIP companys
Run Code Online (Sandbox Code Playgroud)

我(想)我知道如何与REST服务器通信并获取我需要的信息.我将使用这样的API实现REST Client类

public List<Customer> getCustomers();
public Customer getCustomer(final String id);
public List<Customer> getVipCustomer();

public List<Company> getCompanies();
public Customer getCompany(final String id);
public List<Customer> getVipCompanies();
Run Code Online (Sandbox Code Playgroud)

参考了Virgil Dobjanschi的" 开发Android REST客户端应用程序 " 演示文稿,我了解到在Activity的Worker Thread中处理REST请求并不是一个好主意.相反,我应该使用服务 API.

我喜欢将Singleton ServiceHelper绑定到(本地)服务的想法,但我担心我不理解服务概念是否正确.

目前我不明白如何将REST调用结果(在服务中完成异步)报告回调用者Activity.我也想知道我是否需要一个服务来处理所有REST请求(具有不同的返回类型),或者我是否需要为每个REST请求提供专用服务.

可能我还有很多其他的理解问题,所以对我来说最好的事情就是满足我需求的示例应用程序.我的用例并不罕见,我希望那里有示例应用程序.

你能让我知道吗

任何其他建议指出我在正确的实现方向也是有帮助的(Android API-Demo与我的用例不匹配).

提前致谢. …

java rest android design-patterns

82
推荐指数
4
解决办法
4万
查看次数

标签 统计

android ×1

design-patterns ×1

java ×1

rest ×1