项目作者: ByteOliveira

项目描述 :
Simple http request lib for android
高级语言: Java
项目地址: git://github.com/ByteOliveira/AndroidHttpRequest.git
创建时间: 2017-07-04T19:20:46Z
项目社区:https://github.com/ByteOliveira/AndroidHttpRequest

开源协议:GNU General Public License v3.0

下载


Android HTTP Requester

This library is a simple way to do http requests in the android enviroment

Supports

  • POST
  • GET
  • Only HTTP for now

Future work

  • HTTPS
  • Enforce HTTPS use
  • Validing TLS/SSl keys from public key folder

Thanks to Paulo Ribeiro for the firts initial simplification ideia

Usage


GET request

  1. public static void doGet(){
  2. GET.ResponseHandler responseHandler = new GET.ResponseHandler() {
  3. @Override
  4. public void onResponse(byte[] result) {
  5. // TODO: ADD YOUR CODE HERE
  6. }
  7. };
  8. GET get = new GET("http://yoururl.com",responseHandler);
  9. // OR
  10. HashMap<String,String> parameters = new HashMap<>();
  11. parameters.put("key","value");
  12. ...
  13. GET get = new GET("http://yoururl.com",responseHandler,parameters);
  14. }

Post request

  1. public static void doPost(){
  2. POST.ResponseHandler responseHandler = new POST.ResponseHandler(){
  3. @Override
  4. public void onResponse(byte[] result) {
  5. // TODO: ADD YOUR CODE HERE
  6. }
  7. };
  8. HashMap<String,String> properties = new HashMap<>();
  9. properties.put("Content-Type","application/json; charset=UTF-8");
  10. byte[] data = "{'id':'my json obj'}".getBytes();
  11. POST post = new POST("http://yoururl.com",properties,data,responseHandler);
  12. }

License

GNU General Public License v3.0