コード例 #1
0
  @Override
  protected Boolean doInBackground(File... params) {
    String server = BuildConfig.API_BASE_URL;
    ICredentials credentials = new UserCredentials(mContext);
    String url = server + "/api/nodes/" + wmID + "/photos?api_key=" + credentials.getApiKey();
    Log.d(TAG, url);

    File image = params[0];

    HttpClient httpclient = new DefaultHttpClient();
    HttpPost httppost = new HttpPost(url);

    try {
      MultipartEntity entity = new MultipartEntity();
      entity.addPart("photo", new FileBody(image));
      httppost.setEntity(entity);
      HttpResponse response = httpclient.execute(httppost);
      String result = EntityUtils.toString(response.getEntity());
      Log.d(TAG, result + "");
      return true;
    } catch (Exception e) {
      e.printStackTrace();
      Log.d(TAG, e.getLocalizedMessage());
      return false;
    }
  }
コード例 #2
0
 @Override
 public void prepareDatabase() {
   mCredentials.save(mApiKey, mEmail);
 }