android-asynctask

AsyncTask get a wrong String parameter

主宰稳场 提交于 2019-12-24 08:55:49
问题 I'm trying to load bitmaps in the asyncTask, in the onClick I will execute myAsyncTask and get bitmap as result. I'm stuck with NullPointerException, because String parameter, that I put to myAsyncTack is decoded wrong (see logcat screenshot, first line is log.d of String data[position], and the second is from myAsyncTask decode method). In my code I need to open lots of images at background, how can I do it right with myAsyncTask? execute: Log.d("Files", "DATA: " + data[position]); try{

Android - list returns to top after update

不羁的心 提交于 2019-12-24 08:26:01
问题 I have a list that gets refreshed every 2 seconds via the Handler postDelayed() method. Every 2 seconds an AsyncTask is run that makes an HTTP GET request, turns the JSON into a list of objects, then sets the ListAdapter: MyListAdapter adapter = new MyListAdapter(someObjects); setListAdapter(adapter); My problem is that every time the task completes (so, roughly every two seconds) my list jumps back to the top, even if I have scrolled down to the middle or bottom of the list. This would be

AsyncTask and Progressbar

馋奶兔 提交于 2019-12-24 07:59:36
问题 I am writing an application in which I download PDFs one by one and show them in a view. The view has a next button which onClick shows the PDF(that was downloaded on the previous next click) and downloads the next PDF which will be shown when the next button is clicked again. I am downloading the files using AsyncTasks. I have one AsyncTask and a ProgressDialog inside it for each file. If a user clicks next button and if the file to show(that was supposed to be downloaded on previous next

ProgressDialog does not display until after AsyncTask completes

折月煮酒 提交于 2019-12-24 07:25:57
问题 I am trying to display an indefinite ProgressDialog, while an AsyncTask binds to a RemoteService. The RemoteService builds a list of the users contacts when the service is first created. For a long list of contacts this may take 5~10 seconds. The problem I am having, is that the ProgressDialog does not display until after the RemoteService has built it's list of contacts. I even tried putting a Thread.sleep in to give the ProgressDialog time to show up. With the sleep statement the

AsyncTask - Return a String in postExecute to the Activity, which started the Async Task without blocking the UI Thread

淺唱寂寞╮ 提交于 2019-12-24 07:18:07
问题 I have an Activity, which starts an AsyncTask with an Implemented process dialog. That works fine! But i want to get a String return when the asyncTask has finished. So i have to return something in the onPostExecute - Method. That result(string) i want to grab in the Activity, which started the AsyncTask. I do not want to use .get() because it blocks the UI thread. What do i have to write into onPostExecute and the Activity grab the string from doInBackground? Thank you for any kind of help

need more understanding of AsyncTask in android

a 夏天 提交于 2019-12-24 07:15:27
问题 I have this line of code which has no problem at all, the only issue is that every time this code is executed the app waits for all the process to finish making the interface not respond for maybe half a second. the best solution I found was to use a Thread but it causes some issue so I resort to AsyncTask which I am having trouble understanding. Can anyone help me how I can implement it to this line of code? ima.setOnClickListener(new OnClickListener() { public void onClick(View v) { // TODO

Why when I call an AsyncTask from the activity onResume do I not get to see the progressdialog?

狂风中的少年 提交于 2019-12-24 06:59:34
问题 When a user presses a tab in my application - I want a background task to get kicked off which shows a progress bar. I do this by launching a AsyncTask from the onResume() of my activity. The problem is that my progress dialog is not shown when doing this - the background task runs successfully and after the onPostExecute is run focus is returned to my activity and the application continues as normal. How can I launch a AsyncTask from the onResume = or when an activity is started with still

Why when I call an AsyncTask from the activity onResume do I not get to see the progressdialog?

和自甴很熟 提交于 2019-12-24 06:59:17
问题 When a user presses a tab in my application - I want a background task to get kicked off which shows a progress bar. I do this by launching a AsyncTask from the onResume() of my activity. The problem is that my progress dialog is not shown when doing this - the background task runs successfully and after the onPostExecute is run focus is returned to my activity and the application continues as normal. How can I launch a AsyncTask from the onResume = or when an activity is started with still

Android UI Thread Block when calling AsynchTask.get()

一个人想着一个人 提交于 2019-12-24 06:58:35
问题 My activity is a login page. When the user clicks, an asyncTask check in a database if credentials are good. During the task, I want to display a ProgressDialog but after clicking on the button, it stays pressed for 5 seconds and then my ProgressDialog quiclky shows up (less than 1 second) and the toast appears. There is my onClick function : Button connect = (Button)findViewById(R.id.connectButton); final EditText loginED = (EditText) findViewById(R.id.login); final EditText passwordED =