android-asynctask

Android: Proper way to download lots of files

独自空忆成欢 提交于 2019-12-24 17:48:00
问题 In my app I need to download a bunch of files. My original plan was use an individual AsyncTask for each file, so that I can notify the rest of the app when each file is downloaded. I found it testing that while this works, its seems really memory in-efficient. Is there a good way to use a single AsyncTask or maybe a Service to download the files and notify on each files complete? 回答1: There's no reason to use numerous AsyncTask s, since you may create the list of file names, pass it to the

error in running two async task

与世无争的帅哥 提交于 2019-12-24 17:07:05
问题 I am stuck on this stack trace, I don't know what is reason behind it . 06-27 17:05:14.841: W/SingleClientConnManager(1519): Invalid use of SingleClientConnManager: connection still allocated. 06-27 17:05:14.841: W/SingleClientConnManager(1519): Make sure to release the connection before allocating another one. 06-27 17:05:15.031: E/log_tag(1519): Error in http connection java.net.SocketException: Socket closed 06-27 17:05:15.077: E/log_tag(1519): Error converting result java.lang

Android Intent in AsyncTask class giving error

自古美人都是妖i 提交于 2019-12-24 16:33:59
问题 I am new to Android programming and trying to learn the concepts, of course with the help from my fellow Stackoverflow user. What i am trying to do : From the Login page, I am trying to fetch the login credentials from a json file located on a server. After parsing the json file and verifying the login credentials, i am starting a new intent to the next page of my app(Home). Problem : I have successfully done all the networkings operations and parsing on a background thread using AsyncTask,

open failed: EACCES (Permission denied) from IoBridge.java in AsyncTask

允我心安 提交于 2019-12-24 16:27:25
问题 I am trying to download a file through FTP. Basically I am using two tabs fragment of an activity. RemoteTabFragment and LocalTabFragment. In LocalTabFragment, I am listing file in my Download directory. While in RemoteTabFragment, I am listing remote files and there is option to download remote file to local download directory. For FTP operations I am using AsyncTask.Here is doInBackground function of AsyncTask: protected FTPClient doInBackground(Void... args) { Log.d("siteobj", site

Using IMEI as a parameter for JSON Service

喜你入骨 提交于 2019-12-24 16:18:45
问题 after grasping AsyncTask, I have run into yet another road bump. Using JSON (which connects to my local SQLServer, I would like to retrieve an object using the IMEI as a string parameter. I have set a breakpoint to my AsyncTask call and it just crashes, without even walking through. The IMEI of each mobile is stored in my database. I implementing the following AsyncTask with the hope of running it on my device, and not on an emulator. I suspect that it may have to do with my device, as both

Images jumble up in ListView using AsyncTask

雨燕双飞 提交于 2019-12-24 15:34:37
问题 I am loading images directly from mp3's and displaying them along with song title in my app. To smoothen the process I am using an AsyncTask and loading the images in background. If i scroll slowly the images appear in correct order with song. However , if I scroll up and down fast , then the images jumble up for 2-3 seconds (as in appear in an incorrect order). After 2-3 seconds the order again becomes normal. How can I avoid this ? Here is my code : public class TestAcitivity extends

Get gps coordinates with asyncTask

孤人 提交于 2019-12-24 15:12:43
问题 i need to get my current coordinates. i try next, but it is does not get result. public class FragmentNear extends SherlockFragment implements android.location.LocationListener { @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { locationManager = (LocationManager) getActivity().getSystemService( Context.LOCATION_SERVICE); locationManager.requestLocationUpdates( LocationManager.GPS_PROVIDER, 0, 0, this); v = inflater.inflate(R.layout

How to set time out for AsyncTask execution?

只谈情不闲聊 提交于 2019-12-24 14:55:56
问题 I have been trying to create time out while AsyncTask execution more than 1 minute. If the time up, then should exit with Notification. This is my code: private class GetLongLat extends AsyncTask<Void, Void, Void> { @Override protected void onPreExecute() { super.onPreExecute(); longlatDialog = new ProgressDialog(MainActivity.this); longlatDialog.setMessage("Fetching Data. Please wait.."); longlatDialog.setCancelable(false); longlatDialog.show(); } @Override protected Void doInBackground(Void

Async and ListView Android

可紊 提交于 2019-12-24 14:52:14
问题 BackgorundTask.java (How to get the result of OnPostExecute() to main activity because AsyncTask is a separate class?) public class BackgroundTask extends AsyncTask<String,Void,String> { public interface AsyncResponse { void processFinish(String output); } public AsyncResponse delegate = null; public BackgorundTask(AsyncResponse delegate){ this.delegate = delegate; } protected String doInBackground(String... uri) { HttpClient httpclient = new DefaultHttpClient(); HttpResponse response; String

What is best way to pass JSON data one Fragment to another Fragment

北城以北 提交于 2019-12-24 14:16:03
问题 I have two fragments in site my first fragment call AsyncTask and get some json values.and then i want to pass my JSON values to my second Fragment's TextViews.What is the best way pass json value between fragments? this is my AsyncTask in Fragment 1 class LoadingAccountEntry extends AsyncTask<String, String, String> { @Override protected void onPreExecute() { } @Override protected String doInBackground(String... args) { String response; Map<String, Object> data = new LinkedHashMap<String,