androidhttpclient

How to wait for two Async HTTP request complete with loopj HTTP library

拈花ヽ惹草 提交于 2021-02-08 05:20:24
问题 My case is that I need to get two sets of data from sever with two HTTP get request, then process them together. I'm using loopj's http library to do the task. The problem is that since loopj's http is Async, which means I can't determine when they will be complete and which will complete first.They all have their own onSuccess function. I tried to put a boolean flag into each of them, and make the calling activity check the change of AND operation of these two boolean, but seems if I make

POST with Android Retrofit

谁都会走 提交于 2021-02-06 14:58:28
问题 I'm new to Android programming and working with Retrofit. I've done a bunch of research on this topic, but haven't been able to find a solution specific to my needs. I'm working with our API and trying to make a POST request. I successfully achieved this with the following non-Retrofit code: private class ProcessLogin extends AsyncTask<Void, String, JSONObject> { private ProgressDialog pDialog; String email,password; protected void onPreExecute() { super.onPreExecute(); inputEmail = (EditText

How to resolved http and Site Behavior: Navigation error in android app?

匆匆过客 提交于 2020-12-07 06:34:26
问题 Recently I updated android 9 to android 10 but unfortunately, the app sometimes crashes and gives this error. com.fgapps.maker E/chromium: [ERROR:cookie_manager.cc(137)] Strict Secure Cookie policy does not allow setting a secure cookie for http://googleads.g.doubleclick.net/ for apps targeting >= R. Please either use the 'https:' scheme for this URL or omit the 'Secure' directive in the cookie value. I tried using this in manifiest <application android:hardwareAccelerated="false" android

okhttp new JsonObject from Response

血红的双手。 提交于 2020-06-14 06:50:46
问题 I am trying to use OKHttp and https://github.com/hongyangAndroid/okhttp-utils to implement Login function, but I don't know how to create new a JsonObject use Response in the Callback. OkHttpUtils.post() .url(url) .addParams("phone", "18681873411") .addParams("password", "18681873411") .build() .execute(new Callback() { @Override public Object parseNetworkResponse(Response response) throws Exception { Log.i("ws","---->>parseNetworkResponse" + response.body().string()); JSONObject jsonObj =

OKhttp PUT example

强颜欢笑 提交于 2020-05-11 04:08:48
问题 My requirement is to use PUT , send a header and a body to server which will update something in the database. I just read okHttp documentation and I was trying to use their POST example but it doesn't work for my use case (I think it might be because the server requires me to use PUT instead of POST ) . This is my method with POST : public void postRequestWithHeaderAndBody(String url, String header, String jsonBody) { MediaType JSON = MediaType.parse("application/json; charset=utf-8");

OKhttp PUT example

孤街醉人 提交于 2020-05-11 04:07:16
问题 My requirement is to use PUT , send a header and a body to server which will update something in the database. I just read okHttp documentation and I was trying to use their POST example but it doesn't work for my use case (I think it might be because the server requires me to use PUT instead of POST ) . This is my method with POST : public void postRequestWithHeaderAndBody(String url, String header, String jsonBody) { MediaType JSON = MediaType.parse("application/json; charset=utf-8");

Facing difficulty while sending mp3 file from Android to Server

删除回忆录丶 提交于 2020-01-25 14:30:46
问题 I'am trying to send a mp3 file from my Android application to Server. I'am using this method android async http to send mp3 file. This is my code. try { params1.put("file", new ByteArrayInputStream(MeetingFragment.mediafile)); } catch (FileNotFoundException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } AsyncClientHandler.post("events/Uploadrecording/5", params1, new AsyncHttpResponseHandler() { @Override public void onFailure(int statusCode, Throwable error, String content)

show upload progress for JSON

耗尽温柔 提交于 2020-01-15 10:52:48
问题 I have the following piece of code and I would want to add a feature in here such that I know when the JSON content is uploaded. I am uploading a JSON content . @Override protected String doInBackground(JSONObject... params) { // TODO Auto-generated method stub String state = ""; HttpPost httpPost = new HttpPost(commentURL); StringEntity se = null; HttpResponse response = null; HttpEntity entity = null; DefaultHttpClient httpClient = new DefaultHttpClient(); InputStream is = null; try { se =

Android “TAKE PHOTO” - Image which is clicked is getting saved as a corrupt image

时间秒杀一切 提交于 2020-01-05 02:56:07
问题 I have a button, which opens up a dialog box asking user to either "Take Picture" or "Choose from gallery". I am facing issues when user "Take photo" , image is getting clicked, and for verification purpose I am setting Bitmap image inside the circularImage view, but when I go to specified location path of the image, either Image is not there or Image is corrupted. Also I am trying to upload the image to the server using AsyncHttpClient in android but not being able to do it successfully.

Android Volley Library doen't return whole response data

跟風遠走 提交于 2020-01-01 06:26:08
问题 Volley library doesn't return whole response data. It only return the part of the response data. I am calling drupal services. Below is my code for it. public void BoardRoomRequest() { pdialog = new ProgressDialog(BoardRoom.this); pdialog.setTitle("Please wait...."); String url = Global_Application.url + "views/boardroom"; Log.d("url========", url); Map<String, String> params = new HashMap<String, String>(); StringRequest req = new StringRequest(Request.Method.GET, getApplicationContext(),