Android網絡封裝包:IceNet
這個庫是一款Android網絡封裝,由Volley, OkHttp 和 Gson組合組成。
Initialization
public class YourApplications extends Application { ...@Override public void onCreate() { super.onCreate(); initIceNet(); } public void initIceNet() { IceNetConfig config = new IceNetConfig.Builder() .setBaseUrl(BuildConfig.SERVER_URL) .setContext(getApplicationContext()) .build(); IceNet.init(config); } ...
} </pre>
GET REQUEST
IceNet.connect() .createRequest() .get() .pathUrl("/v1/feeds") .fromJsonArray() .mappingInto(Feeds.class) .execute(REQUEST_TAG, callback);
POST REQUEST
IceNet.connect() .createRequest() .post(bodyRequest) .pathUrl("/v1/feed") .fromJsonObject() .mappingInto(PostResponse.class) .execute(REQUEST_TAG, callback);
STRING REQUEST (NEW)
IceNet.connect() .createRequest() .get() .pathUrl("/string") .fromString() .execute("REQUEST_TAG", callback);
項目主頁:http://www.baiduhome.net/lib/view/home/1425221223776
本文由用戶 jopen 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!