【问题标题】:AQuery upload image from local device to serverAQuery从本地设备上传图片到服务器
【发布时间】:2018-06-07 18:00:09
【问题描述】:

我想使用 https://code.google.com/p/android-query/wiki/AsyncAPI 这个库是否支持这个目的?

我是 Android 和 Java 的新手,还很难理解 api。

【问题讨论】:

    标签: java android aquery


    【解决方案1】:
    public void async_post(){
    
    //do a twiiter search with a http post
    
    String url = "http://search.twitter.com/search.json";
    
    Map<String, Object> params = new HashMap<String, Object>();
    params.put("q", "androidquery");
    
    aq.ajax(url, params, JSONObject.class, new AjaxCallback<JSONObject>() {
    
        @Override
        public void callback(String url, JSONObject json, AjaxStatus status) {
    
            showResult(json);
    
        }
    });
    

    }

    【讨论】:

    【解决方案2】:
    private void aync_multipart(){
    
        String url = "https://graph.facebook.com/me/photos";
    
        Map<String, Object> params = new HashMap<String, Object>();
        params.put("message", "Message");
    
        //Simply put a byte[] to the params, AQuery will detect it and treat it as a multi-part post
        byte[] data = getImageData();
        params.put("source", data);
    
        //Alternatively, put a File or InputStream instead of byte[]
        //File file = getImageFile();           
        //params.put("source", file);
    
        AQuery aq = new AQuery(getApplicationContext());
        aq.auth(handle).ajax(url, params, JSONObject.class, this, "photoCb");
    }
    

    发件人:https://code.google.com/p/android-query/wiki/AsyncAPI#Http_POST_(Multipart)

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-06-08
      • 2012-02-19
      • 1970-01-01
      • 1970-01-01
      • 2011-06-01
      相关资源
      最近更新 更多