android-asynctask

how to call async task with different url

China☆狼群 提交于 2019-12-25 06:38:38
问题 I need to call asynctask with different urls. i have three button, they do a http post to server with different urls, now i can call asynctask with one url but how can i call the same function with different urls.the following is my asynctask class: private class Downloadfiles extends AsyncTask<URL, Integer, JSONObject>{ @Override protected void onPostExecute(JSONObject jo) { try { cards = jo.getInt("cards"); points = jo.getInt("points"); cash = jo.getInt("cash"); } catch (JSONException e1) {

ksoap2 AsyncTask PropertyInfo not recevied to webservice, why?

强颜欢笑 提交于 2019-12-25 06:34:55
问题 I need to send some parameters to my web service and get result. I have used ksoap2-android-assembly-2.4-jar-with-dependencies.jar in lib, my web service work properly : [WebMethod] public string TestParams(string userName, string password, string startRowIndex, string maximumRows, string OrderType, string IdOpera) { return userName + " - " + password + " - " + startRowIndex + " - " + maximumRows + " - " + OrderType + " - " + IdOpera; } In main java code : private class AsyncCall extends

Android: How to detect when multiple http requests complete

删除回忆录丶 提交于 2019-12-25 06:02:19
问题 I have this app that onResume() creates five fragments. Each fragment then opens a http connection to download an XML file. This is done using an AsyncTask. In the async tasks onPostExecute() the XML file is processed and the result rendered in a tab. I'm trying to figure out how to display a "Loading..." screen that is removed when the last fragments XML file is processed. I've looked at onPreExecute() to setup a ProgressDialog but I only want to do it once... I could create a counter that

Android: How to detect when multiple http requests complete

99封情书 提交于 2019-12-25 06:02:12
问题 I have this app that onResume() creates five fragments. Each fragment then opens a http connection to download an XML file. This is done using an AsyncTask. In the async tasks onPostExecute() the XML file is processed and the result rendered in a tab. I'm trying to figure out how to display a "Loading..." screen that is removed when the last fragments XML file is processed. I've looked at onPreExecute() to setup a ProgressDialog but I only want to do it once... I could create a counter that

Canceling AsyncTask that is not running Calls onCancelled?

天大地大妈咪最大 提交于 2019-12-25 05:56:09
问题 I have an Asynctask B that is executed from activity A. On post execute of that B, on a certain condition B might create a new instance of itself and execute it. What i did is put the AsyncTask declaration as global inside the B and overridden the onCancelled of B to cancel the new instance that is created onpostexecute. so onDestroy of Activity A b.cancel() will also cancel the any AsyncTask executed onPostExecute. @Override protected void onCancelled() { if(currentPlansAsync != null) {

Android leaked window

亡梦爱人 提交于 2019-12-25 05:31:37
问题 I am using AsyncTask to gather data, and then start a new activity, but I am getting a leaked window. class GetDataTask extends AsyncTask<Void, Void, Void> { @Override protected void onPreExecute() { mProgressDialog = new ProgressDialog(getActivity()); mProgressDialog.setMessage("Getting schedule for "+selectedSport+"..."); mProgressDialog.setCancelable(false); mProgressDialog.show(); } @Override protected Void doInBackground(Void... params) { XmlPullFeedParser xpfp = new XmlPullFeedParser

Android leaked window

限于喜欢 提交于 2019-12-25 05:31:16
问题 I am using AsyncTask to gather data, and then start a new activity, but I am getting a leaked window. class GetDataTask extends AsyncTask<Void, Void, Void> { @Override protected void onPreExecute() { mProgressDialog = new ProgressDialog(getActivity()); mProgressDialog.setMessage("Getting schedule for "+selectedSport+"..."); mProgressDialog.setCancelable(false); mProgressDialog.show(); } @Override protected Void doInBackground(Void... params) { XmlPullFeedParser xpfp = new XmlPullFeedParser

How to show toast according to the JSONObject response

旧巷老猫 提交于 2019-12-25 05:28:07
问题 I am doing an application in which I'm using username and password for log in, if log in is successful I'm getting user_id and all, but when invalid user try to log in, will have to show toast message to the user. I'm getting {"error":"invalid_grant"} as my JSONresponse and I'm able to get JSONObject in a string. JSONObject jObject = new JSONObject(result); String aJsonString = jObject.getString("error"); Here aJsonString have the value of error in it. Now, my question is: How to show an

Exception in AsyncTask due to enormous number of data

感情迁移 提交于 2019-12-25 05:25:34
问题 I am connecting from my Android app to a RESTful Web Service in Java. I am using AsyncTask to fetch the data. It works perfectly for normal amount of data. but when I have a huge amount of data, an Exception happens in the Android app. I tried to catch this exception, but I couldn't: private class LoadingDataFromServer extends AsyncTask<Void, Void, Void> { private boolean outOfMemory = false; @Override public void onPreExecute() { progress = ProgressDialog.show(main_activity, null,"Loading ..

Android: AsyncTask UI update issue

此生再无相见时 提交于 2019-12-25 05:08:35
问题 In the code below, I'm trying to create a ListActivity . The elements of this list are being filled by a custom ArrayAdapter - OrderAdapter. All the element fetching mechanism is inside the AsyncTask class. I'm able toset the elements in the m_adapter , but not able to update the UI of List. The activity is getting force closed. Code: public class SoftwarePassionView extends ListActivity { private ProgressDialog m_progressDialog = null; private ArrayList<Order> m_orders = null; private