android-async-http

get android AsyncHttpClient response after it finish

岁酱吖の 提交于 2021-01-29 08:22:04
问题 hello i am using AsyncHttpClient to send request to restful api the problem is i want to have the result in onSuccess and pass it from the class who have this method to my activity public int send(JSONObject parameters,String email,String password){ int i =0; try { StringEntity entity = new StringEntity(parameters.toString()); entity.setContentType(new BasicHeader(HTTP.CONTENT_TYPE, "application/json")); client.setBasicAuth(email,password); client.post(context, "http://10.0.2.2:8080/webapi

Difference between RequestParams add() and put() in AndroidAsyncHttp

泪湿孤枕 提交于 2020-01-11 08:30:09
问题 While using the android-async-http library I stumbled upon params.add() . I've been using params.put() for a while and it seems better than add() since it allows data types other than String (like int , long , object , file ) while add() does not. RequestParams params = new RequestParams(); // So how is this params.add("param_a", "abc"); // different from this params.put("param_a", "abc"); // and which one should I use? 回答1: The major difference between the two (other than add() 's String

AndroidAsyncHttp Error

核能气质少年 提交于 2020-01-05 08:21:23
问题 I'm trying to implement the LoopJ AndroidAsyncHttp for a Braintree project. I downloaded the .jar file and added it as a library. I now have the following code: public class PayCharge extends Activity { AsyncHttpClient client = new AsyncHttpClient(); @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.paycharge); client.get("https://xxx.herokuapp.com/generateToken.php", new TextHttpResponseHandler() { @Override public void

An error occured while executing doInBackground(). FATAL EXCEPTION:AsyncTask #10 [duplicate]

a 夏天 提交于 2019-12-25 17:44:24
问题 This question already has answers here : How to fix 'android.os.NetworkOnMainThreadException'? (55 answers) Closed 5 years ago . On the click event add data to MySQL database through php on the localhost. Its showing following logcat error on the click event. Please help me to solve this problem. 08-11 07:31:06.416: D/gralloc_goldfish(971): Emulator without GPU emulation detected. 08-11 07:31:53.377: D/Inside Click(971): aaaaaaa 08-11 07:31:53.837: D/inid doinbackground(971): aaaaaaa 08-11 07

Caused by: java.lang.IllegalArgumentException: Host name may not be null

我只是一个虾纸丫 提交于 2019-12-24 02:43:09
问题 I am using four Strings in my code. The first String contains " http:// ", the second String contains user host URL (entered by user), the third contains " /musics/a.mp3 " and the fourth String contains complete URL, by combining the previous Strings, like this: String fourth = first+second+third; Then I'm using the fourth String in AsyncTask 's execute, like this: new JSONAsyncTask().execute(fourth); And I'm getting the error below. Log: 10-07 06:17:15.934: E/AndroidRuntime(1194): FATAL

How to upload multiple files with AsyncHttpClient Android

放肆的年华 提交于 2019-12-21 11:05:02
问题 I know I can upload single file from AsyncHttpClient http://loopj.com/android-async-http/ File myFile = new File("/path/to/file.png"); RequestParams params = new RequestParams(); try { params.put("profile_picture", myFile); } catch(FileNotFoundException e) {} But I have to upload multiple files to the server with multipart post. How can I do that? 回答1: You can pass a file array as value for the files key. In order to do that, follow the code below: File[] myFiles = { new File("pic.jpg"), new

How to upload multiple files with AsyncHttpClient Android

一个人想着一个人 提交于 2019-12-21 11:04:48
问题 I know I can upload single file from AsyncHttpClient http://loopj.com/android-async-http/ File myFile = new File("/path/to/file.png"); RequestParams params = new RequestParams(); try { params.put("profile_picture", myFile); } catch(FileNotFoundException e) {} But I have to upload multiple files to the server with multipart post. How can I do that? 回答1: You can pass a file array as value for the files key. In order to do that, follow the code below: File[] myFiles = { new File("pic.jpg"), new

how to make HTTPS calls using AsyncHttpClient?

旧时模样 提交于 2019-12-17 17:59:08
问题 i was using AsyncHttpClient link for making http calls but now our server has migrated to HTTPS and I am getting exception javax.net.ssl.SSLPeerUnverifiedException: No peer certificate . Has anyone tried making https call using this library ? initialization of AsyncHttpClient :- AsyncHttpClient client = new AsyncHttpClient(); PersistentCookieStore myCookieStore = new PersistentCookieStore( getActivity()); // List<Cookie> cookies = myCookieStore.getCookies(); myCookieStore.clear(); // cookies

android Wear 5.0 can't resolve host (Http , AsyncClient ETC. )

三世轮回 提交于 2019-12-12 03:25:41
问题 I ve developed Android Wear App also SDK is 4.4AW. After finished that applitacion I tested on new android wear SDK that is 5.0.1 Emulator AND motorola360(with 5.0.1) then I recived this errror (Show in the below) Message Sum: can't resolve host Detailed Message: Unable to resolve host "URL": No address associated with hostname The App works perfect on 4.4 android wear but failed on 5.0.1 (I used Android studio and there is no Error before execution , Successful Build, Crash on Emulator.) Im

How to convert bitmap to File without compressing

非 Y 不嫁゛ 提交于 2019-12-10 10:08:30
问题 I need to download image from a server and save it in its original quality, but apparently the after saving the image is compressed and the quality decreased. I use android-async-http library for http requests. my code of the request and saving file: AsyncHttpClient client = new AsyncHttpClient(); client.get(url, new AsyncHttpResponseHandler() { @Override public void onSuccess(int arg0, Header[] arg1, byte[] response) { BitmapFactory.Options bmOptions = new BitmapFactory.Options(); bmOptions