private void queryMovie(String SearchString) { String strURL = ""; try { strURL = URLEncoder.encode(SearchString, "UTF-8"); } catch (UnsupportedEncodingException e) { e.printStackTrace(); Toast.makeText(this, "Error : " + e.getMessage(), Toast.LENGTH_LONG).show(); } AsyncHttpClient asyncHttpClient = new AsyncHttpClient(); asyncHttpClient.get( QUERY_URL + strURL, new JsonHttpResponseHandler() { @Override public void onSuccess(JSONObject jsonObject) { MovieSearchActivity.jsonObject = jsonObject; mDialog.dismiss(); Toast.makeText(getApplicationContext(), "Success !", Toast.LENGTH_LONG).show(); Log.d("BMF Finder", jsonObject.toString()); updateData(jsonObject); } @Override public void onFailure(int statusCode, Throwable throwable, JSONObject error) { mDialog.dismiss(); Toast.makeText( getApplicationContext(), "Error : " + statusCode + " " + throwable.getMessage(), Toast.LENGTH_LONG) .show(); Log.e("BMFinder", statusCode + " " + throwable.getMessage()); } }); }
@Override public void onColorChanged(int color) { picker.setOldCenterColor(picker.getColor()); picker2.setOldCenterColor(picker2.getColor()); refreshBackgroundColors(); if (!requestPending) { requestPending = true; AsyncHttpClient client = new AsyncHttpClient(); client.get( SettingsFragment.ip + "color?color&" + colorToString(Color.red(picker.getColor()) * getAlpha(picker.getColor())) + "&" + colorToString(Color.green(picker.getColor()) * getAlpha(picker.getColor())) + "&" + colorToString(Color.blue(picker.getColor()) * getAlpha(picker.getColor())) + "&" + colorToString(Color.red(picker2.getColor()) * getAlpha(picker2.getColor())) + "&" + colorToString(Color.green(picker2.getColor()) * getAlpha(picker2.getColor())) + "&" + colorToString(Color.blue(picker2.getColor()) * getAlpha(picker2.getColor())) + "", new AsyncHttpResponseHandler() { @Override public void onFinish() { requestPending = false; } }); } }
public void getSelfFeed(String url, JsonHttpResponseHandler responseHandler) { RequestParams params = new RequestParams(); params.put("access_token", client.getAccessToken().getToken()); mSyncClient.get(url, params, responseHandler); // client.get(REST_URL + SELF_FEED_URL, params, responseHandler); // client.get(REST_URL + SELF_FEED_URL, null, responseHandler); }
private void loadThingTypes() { if (mAsyncHttpClient != null) { startProgressIndicator(); mRequestHandle = mAsyncHttpClient.get( openHABBaseUrl + "rest/thing-types", new AsyncHttpResponseHandler() { @Override public void onSuccess(int statusCode, Header[] headers, byte[] responseBody) { stopProgressIndicator(); String jsonString = null; try { jsonString = new String(responseBody, "UTF-8"); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } Log.d(TAG, "Thing types request success"); Log.d(TAG, jsonString); GsonBuilder gsonBuilder = new GsonBuilder(); Gson gson = gsonBuilder.create(); mThingTypes.clear(); mThingTypes.addAll(Arrays.asList(gson.fromJson(jsonString, ThingType[].class))); mDiscoveryInboxAdapter.setThingTypes(mThingTypes); mDiscoveryInboxAdapter.notifyDataSetChanged(); } @Override public void onFailure( int statusCode, Header[] headers, byte[] responseBody, Throwable error) { stopProgressIndicator(); Log.d(TAG, "Thing types request failure: " + error.getMessage()); } }); } }
private void populateData() { // String query = etQuery.getText().toString(); String searchUrl = "https://ajax.googleapis.com/ajax/services/search/images?q=" + query + "&v=1.0&rsz=8&start=" + imageNumber; searchUrl += setUrlWithImageSettings(); Log.d("DEBUG", "SEARCH IRL IS " + searchUrl); imageNumber += 8; // Toast.makeText(this, "Searching for \""+query+"\"", Toast.LENGTH_SHORT).show(); AsyncHttpClient client = new AsyncHttpClient(); client.get( searchUrl, new JsonHttpResponseHandler() { @Override public void onSuccess(int statusCode, Header[] headers, JSONObject response) { Log.d("DEBUG", response.toString()); JSONArray imageResultsJSON = null; try { imageResultsJSON = response.getJSONObject("responseData").getJSONArray("results"); aImageResults.addAll(ImageResult.fromJSONArray(imageResultsJSON)); } catch (JSONException e) { e.printStackTrace(); } Log.d("imageArray", imageResults.toString()); } }); }
/** * Performs a GET request to the Singly API. * * <p>All network communication is performed in a separate thread. As such it is fine to call this * method from the main UI thread. * * <p>The AsyncApiResponseHandler parameter is an asynchronous callback handler that is used to * retrieve the result of the network request to the API. On success the response from the API is * returned. On failure a Throwable error object will be returned. * * <p>If an API call requires an access token it must be added to the queryParams passed into the * method. * * @param context The current android context. * @param apiEndpoint The Singly API endpoint to call. * @param queryParams Any query parameters to send along with the request. * @param responseHandler An asynchronous callback handler for the request. * @see https://singly.com/docs/api For documentation on Singly api calls. * @see SinglyUtils#getAccessToken(Context) */ public void doGetApiRequest( Context context, String apiEndpoint, Map<String, String> queryParams, final AsyncApiResponseHandler responseHandler) { // get the http client and add api url AsyncHttpClient client = new AsyncHttpClient(); Map<String, String> params = new LinkedHashMap<String, String>(); if (queryParams != null) { params.putAll(queryParams); } String getApiCallUrl = SinglyUtils.createSinglyURL(apiEndpoint); RequestParams rparms = params.isEmpty() ? null : new RequestParams(params); System.out.println(getApiCallUrl); // do an async get request client.get( getApiCallUrl, rparms, new AsyncHttpResponseHandler() { @Override public void onSuccess(String response) { responseHandler.onSuccess(response); } @Override public void onFailure(Throwable error) { responseHandler.onFailure(error); } }); }
private void asynCallToGoogleApi(String strQuery) { AsyncHttpClient asyncHttpClient = new AsyncHttpClient(); // https://ajax.googleapis.com/ajax/services/search/images?v=1.0&q=barack&obama&userip=INSERT-USER-IP String apiUrlCall = String.format(GOOGLE_API_URL, start, Uri.encode(strQuery)); start += 8; apiUrlCall = addQueryParams(apiUrlCall); Log.d("DEBUG", apiUrlCall.toString()); asyncHttpClient.get( apiUrlCall, new JsonHttpResponseHandler() { @Override public void onSuccess(int statusCode, Header[] headers, JSONObject response) { JSONArray jsonImageResults = null; try { jsonImageResults = response.getJSONObject("responseData").getJSONArray("results"); imageResults.addAll(ImageResult.fromJsonArray(jsonImageResults)); imageResultArrayAdapter.notifyDataSetChanged(); Log.d("DEBUG", imageResults.toString()); } catch (JSONException e) { // TODO Auto-generated catch block e.printStackTrace(); } } }); }
public static void getBooks(final String url, final CallBack callBack) { List<Book> list = null; if (TextUtils.isEmpty(url)) { callBack.callback(list); } AsyncHttpClient client = new AsyncHttpClient(); client.get( url, new JsonHttpResponseHandler() { @Override public void onSuccess(int statusCode, Header[] headers, JSONObject response) { List<Book> list = parseBooks(response); if (callBack != null) { callBack.callback(list); } } @Override public void onSuccess(int statusCode, Header[] headers, JSONArray timeline) {} @Override public void onFailure( int statusCode, Header[] headers, String responseString, Throwable throwable) { super.onFailure(statusCode, headers, responseString, throwable); } }); }
private void getPostMark() { if (mApplication.isLogin()) { RequestParams params = new RequestParams(); params.put("userId", mApplication.getUser().getId() + ""); params.put("talkId", post.getId() + ""); String url = getString(R.string.interface_domainName) + getString(R.string.interface_getpostmark); mClient.get( url, params, new JsonHttpResponseHandler() { @Override public void onSuccess(int statusCode, Header[] headers, JSONObject response) { // TODO Auto-generated method stub super.onSuccess(statusCode, headers, response); if (null != response && response.has("state")) { try { if (response.getString("state").equalsIgnoreCase("ok")) { String result = response.getString("msg"); if (-1 < result.indexOf("dashang")) { isReward = true; } if (-1 < result.indexOf("collect")) { isCollect = true; } setButtonFunction(); } } catch (Exception e) { // TODO: handle exception } } } }); } }
public void fetchPopularPhotos() { String url = "https://api.instagram.com/v1/media/popular?client_id=" + CLIENT_ID; // create a network client AsyncHttpClient client = new AsyncHttpClient(); client.get( url, null, new JsonHttpResponseHandler() { // on success @Override public void onSuccess(int statusCode, Header[] headers, JSONObject response) { // expecting a JSON object // iterate each item and decode the item into a java object JSONArray photosJSON = null; try { photosJSON = response.getJSONArray("data"); // iterate for (int i = 0; i < photosJSON.length(); i++) { // get the JSON obj JSONObject photoJSON = photosJSON.getJSONObject(i); // decode the attributes of the json into a data model InstagramPhoto photo = new InstagramPhoto(); photo.username = photoJSON.getJSONObject("user").getString("username"); photo.caption = photoJSON.getJSONObject("caption").getString("text"); photo.imageUrl = photoJSON .getJSONObject("images") .getJSONObject("standard_resolution") .getString("url"); photo.profileImageUrl = photoJSON.getJSONObject("user").getString("profile_picture"); photo.imageHeight = photoJSON .getJSONObject("images") .getJSONObject("standard_resolution") .getInt("height"); photo.likesCount = photoJSON.getJSONObject("likes").getInt("count"); photo.createdTime = photoJSON.getLong("created_time"); photo.type = photoJSON.getString("type"); photo.comments = photoJSON.getJSONObject("comments").getJSONArray("data"); photos.add(photo); } } catch (JSONException e) { e.printStackTrace(); } aPhotos.notifyDataSetChanged(); swipeContainer.setRefreshing(false); } @Override public void onFailure( int statusCode, Header[] headers, Throwable throwable, JSONArray errorResponse) { super.onFailure(statusCode, headers, throwable, errorResponse); } }); }
public static void get( String url, RequestParams params, AsyncHttpResponseHandler responseHandler) { Log.e("App Keys Response", "=AA " + params); Log.e("go hit responseHandler", "===" + responseHandler); Log.e("go hit url", "===" + url); client.get(getAbsoluteUrl(url), params, responseHandler); }
/** public void run */ public void run() { while (!Thread.currentThread().isInterrupted()) { // System.out.println(String.format("sentiment thread: (%d, %d)", this.m_inQueue.size(), // this.m_outQueue.size())); try { final Tweet t = m_inQueue.take(); // build the url String urlString = "http://www.sentiment140.com/api/classify?text=" + URLEncoder.encode(t.text) + "&query=" + URLEncoder.encode(t.keyword); // send off the request AsyncHttpClient client = new AsyncHttpClient(); client.get( urlString, new AsyncHttpResponseHandler() { @Override public void onSuccess(String response) { // parse the sentiment from response t.sentiment = Integer.parseInt((response.split("\"polarity\":")[1]).split(",")[0]); t.sentiment = (t.sentiment / 2) - 1; m_outQueue.offer(t); } @Override public void onFailure(Throwable thrwbl, String string) { System.out.println("sentiment request failed..."); long currentTime = System.currentTimeMillis(); // only show one per minute if (currentTime > m_LastWarningTime + 60000) { m_webToasts.offer( new WebToast( "warning", "We're having some trouble talking to the sentiment server. We'll keep trying, but you might want to check your internet connection.", "Warning", 0, 0, 0)); m_LastWarningTime = currentTime; } } }); } catch (InterruptedException ex) { // immediately reset interrupt flag Thread.currentThread().interrupt(); } } }
@Override public RequestHandle executeSample( AsyncHttpClient client, String URL, Header[] headers, HttpEntity entity, ResponseHandlerInterface responseHandler) { return client.get(this, URL, headers, null, responseHandler); }
private void saveJSONToDatabse() { AsyncHttpClient cliente = new AsyncHttpClient(); cliente.get( URLPOSTS, new JsonHttpResponseHandler() { @Override public void onSuccess(int statusCode, Header[] headers, JSONArray response) { for (int i = 0; i < response.length(); i++) { try { JSONObject jsonobject = response.getJSONObject(i); ContentValues contentValues = new ContentValues(); contentValues.put(JobDbData._ID, jsonobject.getInt("id")); contentValues.put(JobDbData.COLUMN_TITLE, jsonobject.getString("title")); contentValues.put( JobDbData.COLUMN_DESCRIPTION, jsonobject.getString("description")); contentValues.put( JobDbData.COLUMN_POSTED_DATE, jsonobject.getString("posted_date")); getContentResolver().insert(JobDbData.CONTENT_URI, contentValues); JSONArray jsonArray = jsonobject.getJSONArray("contacts"); for (int k = 0; k < jsonArray.length(); k++) { String numerocontact = jsonArray.getString(k); ContentValues contentValues2 = new ContentValues(); contentValues2.put(ContactDbData.COLUMN_JOB_ID, jsonobject.getInt("id")); contentValues2.put(ContactDbData.COLUMN_NUMBER, numerocontact); getContentResolver().insert(ContactDbData.CONTENT_URI, contentValues2); ; } } catch (JSONException e) { e.printStackTrace(); } } progressDialog.dismiss(); fillListViewFromDB(); } @Override public void onFailure( int statusCode, Header[] headers, Throwable throwable, JSONArray errorResponse) { // Log.d("onFailure", "onFailure", throwable); Log.i("Error !", "Ocurrio un error al conectarse al servidor!"); // Toast.makeText(ListadoActivity.class,"") AlertDialog.Builder builder = new AlertDialog.Builder(ListadoActivity.this); builder .setTitle("Error !") .setMessage("Ocurrio un error al conectarse al servidor!") .show(); } }); }
public void invokeWS(RequestParams params, String lienWebService, final String lienJavascript) { // Show Progress Dialog prgDialog.show(); // Make RESTful webservice call using AsyncHttpClient object AsyncHttpClient client = new AsyncHttpClient(); RequestHandle requestHandle = client.get( lienWebService, params, new AsyncHttpResponseHandler() { // When the response returned by REST has Http response code '200' @Override public void onSuccess(String response) { // Hide Progress Dialog prgDialog.hide(); jsonResponse = response; webView = (WebView) findViewById(R.id.web); webView.addJavascriptInterface(new WebAppInterface(), "Android"); webView.getSettings().setJavaScriptEnabled(true); webView.loadUrl(lienJavascript); } // When the response returned by REST has Http response code other than '200' @Override public void onFailure(int statusCode, Throwable error, String content) { // Hide Progress Dialog prgDialog.hide(); // When Http response code is '404' if (statusCode == 404) { Toast.makeText( getApplicationContext(), "Requested resource not found", Toast.LENGTH_LONG) .show(); } // When Http response code is '500' else if (statusCode == 500) { Toast.makeText( getApplicationContext(), "Something went wrong at server end", Toast.LENGTH_LONG) .show(); } // When Http response code other than 404, 500 else { Toast.makeText( getApplicationContext(), "Unexpected Error occcured! [Most common Error: Device might not be connected to Internet or remote server is not up and running]", Toast.LENGTH_LONG) .show(); } } }); }
public static void get( String query, int offset, String imageSize, String imageType, String imageColor, String siteFilter, AsyncHttpResponseHandler handler) { client.get( getFullUrl(query, offset, imageSize, imageType, imageColor, siteFilter), null, handler); }
private void queryItems(Location location) { double latitude = 0; double longitude = 0; if (location != null) { latitude = location.getLatitude(); longitude = location.getLongitude(); } // Create a client to perform networking AsyncHttpClient client = new AsyncHttpClient(); // Show ProgressDialog to inform user that a task in the background is occurring mDialog.show(); // Have the client get a JSONArray of data // and define how to respond Log.i(TAG, QUERY_URL + "query?lat=" + latitude + "&lon=" + longitude); client.get( QUERY_URL + "query?lat=" + latitude + "&lon=" + longitude, new JsonHttpResponseHandler() { @Override public void onSuccess(JSONArray jsonArray) { // Dismiss the ProgressDialog mDialog.dismiss(); // Display a "Toast" message // to announce your success Toast.makeText(getApplicationContext(), "Items updated!", Toast.LENGTH_LONG).show(); Log.d(TAG, jsonArray.toString()); mJSONAdapter.updateData(jsonArray); } @Override public void onFailure(int statusCode, Throwable throwable, JSONObject error) { // Dismiss the ProgressDialog mDialog.dismiss(); // Display a "Toast" message // to announce the failure Toast.makeText( getApplicationContext(), "Error: " + statusCode + " " + throwable.getMessage(), Toast.LENGTH_LONG) .show(); // Log error message // to help solve any problems Log.e(TAG, statusCode + " " + throwable.getMessage()); } }); }
/** * GET处理 * * @param url 请求的URL * @param params HTTP请求的参数列表及值 * @return HTTPResponse的Text * @throws WebException 发生的错误 */ public void get(final String url, final Map<String, String> params) { RequestParams realParams = new RequestParams(); if (params != null) { Iterator<String> iterators = params.keySet().iterator(); while (iterators.hasNext()) { String key = iterators.next(); String value = params.get(key); realParams.put(key, value); } } Log.e(TAG, url); if (version == PROD || version == STAGING) { client.get( url, realParams, new JsonHttpResponseHandler() { @Override public void onSuccess(int statusCode, Header[] headers, JSONObject response) { super.onSuccess(statusCode, headers, response); callback.onResponse(response); } @Override public void onFailure( int statusCode, Header[] headers, Throwable throwable, JSONObject errorResponse) { super.onFailure(statusCode, headers, throwable, errorResponse); Log.e(TAG, "onFailure 1 " + errorResponse + " @ " + throwable); callback.setWebException(new WebException(throwable.toString())); } @Override public void onFailure( int statusCode, Header[] headers, String responseString, Throwable throwable) { super.onFailure(statusCode, headers, responseString, throwable); Log.e(TAG, "onFailure 2 " + responseString + " @ " + throwable); callback.setWebException(new WebException(throwable.toString())); } }); } else { JSONObject json = new JSONObject(); try { json.put("success", true); } catch (JSONException e) { e.printStackTrace(); } callback.onResponse(json); } }
public void registMember(RequestParams params) { AsyncHttpClient client = new AsyncHttpClient(); client.get( MonoURL.SERVER_URL + MonoURL.REGIST_MEMBER, params, new AsyncHttpResponseHandler() { String response = null; JSONObject obj = null; @Override public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { try { response = new String(arg2, "UTF-8"); obj = new JSONObject(response); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } catch (JSONException e) { e.printStackTrace(); } String status = null; try { // JSON Object status = obj.getString("staus"); if (status.equals("success")) { Intent intentMainActivity = new Intent(PrivacyActivity.this, MainActivity.class); SharedPreferences.Editor editor = sharedpreferences.edit(); editor.putString(Utility.Name, name); editor.putString(Utility.Phone, phone); editor.putString(Utility.Email, email); editor.commit(); startActivity(intentMainActivity); } else if (obj.getString("status").equals("fail")) { Toast.makeText(getApplicationContext(), "회원가입 실패 ", Toast.LENGTH_LONG).show(); } } catch (JSONException e) { e.printStackTrace(); } } @Override public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) {} }); }
@Override public void onActivityCreated(Bundle savedInstanceState) { // TODO Auto-generated method stub super.onActivityCreated(savedInstanceState); Log.i("LIFE", "ALBUM - onActivityCreated"); if (!isFragmentResumed) { AsyncHttpClient clientAlbum = new AsyncHttpClient(); clientAlbum.get(url, getAlbumContestResponseHandler()); setListShown(false); } else { setInfoAdapter(); } }
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { counter = 0; String queryText = etQuery.getText().toString(); if (resultCode == RESULT_OK && requestCode == 1) { Toast.makeText(this, "Searching " + queryText, Toast.LENGTH_SHORT).show(); imageSize = (String) data.getStringExtra("imageSize"); color = (String) data.getStringExtra("color"); imageType = (String) data.getStringExtra("imageType"); siteFilter = (String) data.getStringExtra("siteFilter"); AsyncHttpClient client = new AsyncHttpClient(); // http://ajax.googleapis.com/ajax/services/search/images?v=1.0&q=Apple+Cake&start=4 client.get( "http://ajax.googleapis.com/ajax/services/search/images?rsz=8&" + "start=" + counter + "&v=1.0&q=" + Uri.encode(queryText) + "&as_sitesearch=" + siteFilter + "&imgsz=" + imageSize + "&imgtype=" + imageType + "&imgcolor=" + color, new JsonHttpResponseHandler() { @Override public void onSuccess(JSONObject response) { JSONArray imageJsonResults = null; // Do something with the response try { imageJsonResults = response.getJSONObject("responseData").getJSONArray("results"); System.out.println(imageJsonResults); imageAdapter.clear(); imageAdapter.addAll(ImageResult.fromJsonArray(imageJsonResults)); Log.d("DEBUG", imageResults.toString()); } catch (JSONException e) { e.printStackTrace(); } } }); } }
/** 采用AsyncHttpClient的get方式获取图片 */ private void asyncHttpClientGetBitmapToSdcard() { String url = "http://f.hiphotos.baidu.com/album/w%3D2048/sign=38c43ff7902397ddd6799f046dbab3b7/9c16fdfaaf51f3dee973bf7495eef01f3b2979d8.jpg"; client.get( url, new FileAsyncHttpResponseHandler(getApplicationContext()) { @Override public void onSuccess(int statusCode, Header[] headers, File file) { Logger.e("test", "file path = " + file.getAbsolutePath()); Bitmap bitmap = BitmapFactory.decodeFile(file.getAbsolutePath()); im.setImageBitmap(bitmap); } @Override public void onFailure(int statusCode, Header[] headers, Throwable throwable, File file) {} }); }
private void getToken() { client.get( "https://pacific-tor-4300.herokuapp.com" + "/token", new TextHttpResponseHandler() { @Override public void onSuccess(String content) { System.out.println(content); try { JSONObject response = new JSONObject(content); clientToken = response.getString("client_token"); } catch (JSONException e) { e.printStackTrace(); } // findViewById(R.id.buyButton).setEnabled(true); } }); }
/** 采用AsyncHttpClient的get方式获取图片 */ private void asyncHttpClientGetBitmap() { String url = "http://f.hiphotos.baidu.com/album/w%3D2048/sign=38c43ff7902397ddd6799f046dbab3b7/9c16fdfaaf51f3dee973bf7495eef01f3b2979d8.jpg"; client.get( url, new BinaryHttpResponseHandler() { @Override public void onSuccess(int statusCode, Header[] headers, byte[] binaryData) { Bitmap bitmap = BitmapFactory.decodeByteArray(binaryData, 0, binaryData.length, new Options()); im.setImageBitmap(bitmap); } @Override public void onFailure( int statusCode, Header[] headers, byte[] binaryData, Throwable error) {} }); }
public void clickJavier() { httpClient.get( METRO_STEP3, new AsyncHttpResponseHandler() { @Override public void onSuccess(String response) { System.out.println("metrobank5 response " + response); // myProgressDialog.dismiss(); clickFinal(); } public void onFailure(Throwable error, String content) { System.out.println("metrobank2 e1rror " + content); myProgressDialog.dismiss(); } }); }
private void setdata() { AsyncHttpClient client = new AsyncHttpClient(); String url = "http://" + App.ip + "/chat/getAllUserInfor.php?username="******"name"); String p2 = jsonObject.getString("sexual"); textView1.setText("昵称:" + p1 + " (" + p2 + ")"); String p3 = jsonObject.getString("age"); String p4 = jsonObject.getString("mywords"); textView3.setText("个性签名:" + p4); String p5 = jsonObject.getString("class"); textView2.setText("专业:" + p5); String p6 = jsonObject.getString("totaldistance"); textView4.setText("跑步总里程:" + p6 + "千米"); String p7 = jsonObject.getString("totaltime"); textView5.setText("投入时间:" + p7 + "秒"); String p8 = jsonObject.getString("totalenergy"); textView7.setText("甩掉的肥肉:" + p8 + " 斤"); String p9 = jsonObject.getString("totalrunning"); textView6.setText("跑步总次数:" + p9 + " 次"); } catch (JSONException e) { e.printStackTrace(); } } @Override public void onFailure(int i, Header[] headers, byte[] bytes, Throwable throwable) {} }); }
public void send(ResponseListener listener, long roomId) { this.responseListener = listener; AsyncHttpClient asyncHttpClient = new AsyncHttpClient(); asyncHttpClient.setTimeout(TIME_OUT); RequestParams requestParams = new RequestParams(); JniDanmu jniDanmu = new JniDanmu(context.getApplicationContext()); String time = String.valueOf(60L * (System.currentTimeMillis() / 1000L / 60L)); String roomStr = "room/" + roomId + "?"; String str1[] = new String[] {"aid", "client_sys", "time"}; String str2[] = new String[] { URLEncoder.encode("android"), URLEncoder.encode("android"), URLEncoder.encode(time) }; String str3[] = new String[] {}; String str4[] = new String[] {}; String result = jniDanmu.makeUrl(context.getApplicationContext(), roomStr, str1, str2, str3, str4, 1); asyncHttpClient.get( context, NetConfig.getRoomDetailInfoUrl(result), requestParams, responseHandler); }
public void onLoadMore(View v) { counter += 8; String queryText = etQuery.getText().toString(); AsyncHttpClient client = new AsyncHttpClient(); // http://ajax.googleapis.com/ajax/services/search/images?v=1.0&q=Apple+Cake&start=4 client.get( "http://ajax.googleapis.com/ajax/services/search/images?rsz=8&" + "start=" + counter + "&v=1.0&q=" + Uri.encode(queryText) + "&as_sitesearch=" + siteFilter + "&imgsz=" + imageSize + "&imgtype=" + imageType + "&imgcolor=" + color, new JsonHttpResponseHandler() { @Override public void onSuccess(JSONObject response) { JSONArray imageJsonResults = null; // Do something with the response try { imageJsonResults = response.getJSONObject("responseData").getJSONArray("results"); System.out.println(imageJsonResults); // imageResults.clear(); imageAdapter.clear(); imageAdapter.addAll(ImageResult.fromJsonArray(imageJsonResults)); Log.d("DEBUG", imageResults.toString()); } catch (JSONException e) { e.printStackTrace(); } } }); }
public void clickFinal() { httpClient.get( METRO_STEP4, new AsyncHttpResponseHandler() { @Override public void onSuccess(String response) { System.out.println("metrobank5 response " + response); // myProgressDialog.dismiss(); BancoVO ban = parceaDatos(response); ban.datos(); // imprime los 5 campos del bean accountDetails.setText(ban.getDatos()); } public void onFailure(Throwable error, String content) { System.out.println("metrobank2 e1rror " + content); myProgressDialog.dismiss(); } }); }
public void onClick(View v) { yes.setEnabled(false); no.setEnabled(false); switch (v.getId()) { case R.id.yes: feedback = "yes"; break; case R.id.no: feedback = "no"; break; } final String request_url = "http://freelunchforyou.appspot.com/GiveFeedback"; AsyncHttpClient httpClient = new AsyncHttpClient(); RequestParams params = new RequestParams(); params.put("feedback", feedback); params.put("event_name", event_name); httpClient.get( request_url, params, new AsyncHttpResponseHandler() { @Override public void onSuccess(int statusCode, Header[] headers, byte[] response) { Log.i("LOAD WORKERS ", "Successfully give feedbacks"); Toast.makeText( getApplicationContext(), "Give feedbacks successfully ", Toast.LENGTH_SHORT) .show(); Intent intent = new Intent(context, FreeLunchList.class); intent.putExtra(EXTRA_MESSAGE, msg); startActivity(intent); } @Override public void onFailure( int statusCode, Header[] headers, byte[] errorResponse, Throwable e) { Log.e("LOAD WORKERS ", "There was a problem in retrieving the url : " + e.toString()); } }); }