Questions tagged [android-asynctask]

1

votes
0

answer
79

Views

Asynctask not executing while running but executing in debugging

Am executing two AsyncTask in an sequence manner. While debugging its working fine. But while running the app, second AysncTask not executing. Tried with THREAD_POOL_EXECUTOR not helping.below is my code.I don't have any idea about this problem.Below is my complete code.While running headerList.size...
Siva
1

votes
0

answer
48

Views

Most suitable approach for repeated tasks in Android background thread

I'm writing an android application to mock GPS location. Its purpose is to help in testing and once it starts mocking it will be sent to the background. I need to execute a location update every n seconds and that needs to continue when the application is not visible. I'm really confused by the diff...
tomfumb
1

votes
2

answer
242

Views

Calling fragment method from Asynctask PostExecute

I need help on how to call a method that is in a fragment from a class AsyncTask. I've been looking to similar questions, I've tried some things and it has not worked for me. The problem: The AsyncTask class downloads an XML and saves some tags that interest me. Next in the method onPostExecute I ha...
Splanas00
1

votes
1

answer
71

Views

SurfaceView flickering when scrolling

I have a scrollview and nested several custom SurfaceView within. As I scroll, the SurfaceView background begins to flicker black. I have researched this for at least a day now and am unable to find a solution. I have tried to implement the solution of this thread: http://android-coding.blogspot.ca/...
woodenwaffles
1

votes
0

answer
131

Views

Retrieving data in android from Firebase is skipping frames

Trying to retrieve data from Firebase database is skipping frames. I am trying to iterate through 2000 data nodes and saving it in my SQLite database. Rest the activity does not do much just a GIF is shown while the data is loading on the screen. databaseReference.addValueEventListener(new ValueEve...
Saransh Agarwal
1

votes
1

answer
485

Views

How do I fix this “No Such Method Error: No static method”

Hi I have this error I don't know how to solve it : 01-14 20:29:40.081 2584-2584/com.climb.eip.climb E/AndroidRuntime: FATAL EXCEPTION: main Process: com.climb.eip.climb, PID: 2584 java.lang.NoSuchMethodError: No static method getScreenWidthDp(Landroid/content/res/Resources;)I in class Landroid/supp...
Jeremy
1

votes
1

answer
74

Views

Tests never get executed because of the Mockito.doThrow

I am testing an anroid app using Mockito. I want to test an exception case, but the method Mockito.doThrow hangs and the test never gets executed (it neither fails nor succeeds). Here's the code. PackageDownloader represents an AsyncTask. Its method get gets called inside of the downloadPackage meth...
annaoomph
1

votes
1

answer
82

Views

Image uploaded in FTP was 0k with FTPClient

I have a problem with image upload from my android mobile phone to a FTP Area, the FTP work fine, i tried some other interaction with it and i don't have any problem. The uploaded file weight 0k, name and file extension are right, no error or exception. I do a test to copy the file in another folder...
R.Ruzzi
1

votes
3

answer
51

Views

using aSyncTask with variables

I am making a simple weather app and i have a problem with reading variables by aSyncTask. I am very beginner in programming for andorid, so I am asking for understanding. So, i want to put variables 'latitude' and 'longitude' choosen from place picker into asyncTask.execute('Latitude', 'Longitude')...
mistertumek
1

votes
1

answer
153

Views

Android Java Upload Image and then wait to finish asynctask

I am working with AndroidStudio (Java) and there I Post data to URL and upload some images. This process is OK. The problem is that the task is async so it finish after verify other stuff. This is the code: boolean ImgSubidasOK = true; ... btnSubirFotosSistema.setOnClickListener(new View.OnClickLi...
Pato
1

votes
0

answer
26

Views

Searching in an ArrayList Vs Inserting and selecting from Sqllite

In my Android App, I need to get the JSON object from a server. There will be around 2000 JSON objects. I have around 30 String values in a ArrayList. I need to check the 2000 JSON objects and get those 30 values which is there in ArrayList. Question Option # 1 - Searching the JSON objects in 30 dif...
iappmaker
1

votes
0

answer
112

Views

Can we ever use AsyncTask and AsyncTaskLoader in the same project?

I am new to android developing. And i have searched for this answer. Here’s what i know: Both AsyncTask and AsyncTaskLoaders do background processing in Android. The AsyncTaskLoader framework uses AsyncTask. In most cases, it’s better to perform background processes with the loader instead of A...
Kelli Davis
1

votes
0

answer
135

Views

Canvas line chart AsyncTask in RecyclerView android

I put a bitmap at one position of an ArrayList in AsyncTask, and then I show it on ImageView in onViewHolderBind(). But some elements of the list do not display properly What could be the reason for this? @Override protected void onViewHolderBind(List list, RecyclerView.ViewHolder holder, int posi...
user9318253
1

votes
1

answer
64

Views

Android What is the difference between calling AsyncTask.execute vs. extending the AsyncTask?

In Android What is the difference / Advantage between calling AsyncTask.execute(new Runnable.. vs. extending the AsyncTask and calling doInBackground(..)? On some time interval I will use HttpURLConnection to POST to a server and retrieve information. I am not sure which is the preferred method for...
jbg2408
1

votes
1

answer
180

Views

FirebaseAuth listener giving null pointer

I am making a splash screen for my app. While loading of the splash screen I wanted to check if user is logIn or not. If user is Login then i want to show him main activity and if not Login then i wanted to redirect him to the LoginActivitiy. I am using firebase as my backend and...
Aakash
1

votes
0

answer
56

Views

How to create activities based on role of user with restful API?

I am creating an online based Android app which shows notifications from different types of users like 'admin', 'user'. When I login a admin class and layout, or a 'user' its shows another layout and it should open the activity screen based on their role. I'll use intents to open different activitie...
Dr.TZ
1

votes
0

answer
24

Views

Adding large number of views in UI

I am working on an app which have to calculate solution and show calculation steps. Problem is solved by iterative method, which sometimes require large number of steps. All calculation steps are to be shown as Custom Views defined by me. I am adding these views in root view as and when it is prepar...
Ketan Chauhan
1

votes
0

answer
172

Views

IOException: Unable to resolve host “URL”: No address associated with hostname

I am working on an android application. When I run the application on Sony mobile, it runs very well. When I use Huawei mobiles, it doesn't work, and is giving me this exception: IOException: Unable to resolve host 'URL': No address associated with hostname Here are the permissions used: I have trie...
Ahmed.Ouda
1

votes
0

answer
172

Views

Setting Authorization Bearer using Asynctask?

I am getting file not found exception with 405 status code when I try to pass Authorization Bearer using Asynctask and if I comment the line passing Authorization Bearer I am getting 403 with status code. below is my code. class getloantypes extends AsyncTask{ private String LOANURL= 'http://185.78...
Sunil P
1

votes
1

answer
27

Views

Running multiple async tasks returns task to wrong handler

I create several picture objects that each download their own image. But frequently, the same image shows up for several (or all) of the objects. public class Picture { private String userID; private String fileName; private String baseURI; private Bitmap img; public Picture () { this.userID = ''; t...
Aaron Bar
1

votes
1

answer
198

Views

How to fix out of memory error in android while running background thread

I have created an android application that lists videos and plays them. I used AsyncTask to load videos in the background. It takes some time to load videos on the list. But when I close this fragment before it finish loading videos on the list, then it is showing Out Of Memory Error. How to fix th...
Kisan Thapa
1

votes
2

answer
37

Views

Exception apparently thrown but not caught

As the title says, I have code inside 'doInBackground', in AsyncTask. The code reads text from Internet; if something goes wrong (e.g., connexion not available), though, it should signal this situation. Volatile variables are used (and are working) to flag status to another thread, running a Timer....
A Koscianski
1

votes
3

answer
214

Views

Android AsyncTask RecyclerView does not populate

I want to make an app lister application which fetches the application list via the packagemanager through an AsyncTask nested in a singleton class. However, if and only if I implement the async task, the RecyclerView will not populate on the first OnCreate. I am sure I am doing a silly mistake and/...
itarill
1

votes
1

answer
113

Views

Android Asynctask get last progress in background after destroy activity

What I want to do now is loop download pdf from URL that has about 875 Files. I have already done this by using Asynctask and update the progress in progress dialog also everything is working fine, but what I had a problem is when the user clicks on my DOWNLOAD IN BACKGROUND button, the download is...
Anonymous-E
1

votes
0

answer
104

Views

How to pass response json from android to HTML using android HTML Webview?

I am trying to display response json in android HTML Webview,while clicking the button it will invoke the Activity and loads the asset URL but load() returns null as the responseJsonObject,because before the completion of getData() load() returns responseJsonObject as null.By setting break points an...
N_G
1

votes
0

answer
49

Views

AsyncTask publishProgress not updating on onProgressUpdate when using BufferedReader

I want to update download progress of progress dialog but AsyncTask getting hangs when using BufferedReader. Not calling publishProgress and not updating progress dialog in onProgressUpdate. Also, it's not printing Log into while loop. I have tested using printing Log in my code. First Log is printi...
Chayan Mistry
1

votes
2

answer
228

Views

Is it possible to use object expressions for AsyncTask declaration/initialization using Kotlin?

What I want to do is: val myTask = object: AsyncTask() { {...} } myTask.execute() Or even shorter: (object : AsyncTask() { {...} }).execute() But it gives me 'This AsyncTask class should be static or leaks might occur (...)'. And it seems that I can't subclass and instantiate AsyncTask like I can do...
Fernando Tancini
1

votes
1

answer
79

Views

How can I run the same Asynctask one after one finished

Firstly, i have an arraylist (the data from firebase)which contains stock Strings. Then i need to pass those stock strings to the asynctask . The asynctask is going to get the json from an url so i can get other stock information for constructing my listview. The problem is that i dont know how to p...
Ho Wong
1

votes
0

answer
59

Views

Android threads not starting synchronously

I have a class in which I create a graphview containing words that have been taken from a song and a mediaplayer to play the song when a button is pressed. The graph is displaying 1 second at a time so if I change the coordinates by 0.1 every 100ms. I should get the graphview moving as fast as the s...
kataroty
1

votes
0

answer
58

Views

Using AsyncTask with BufferedReader to get line in a http

I'm trying to use AsyncTask and BufferedReader to read the line shown in the http with the following code. private class DownloadFilesTask extends AsyncTask { @Override protected String doInBackground(Void... params) { String request_url = 'http://www.ryanheise.com/sarcastic.cgi'; try { URL url = n...
Jamen
1

votes
0

answer
56

Views

HttpURLConnection does not take the content website

I have a problem reading the content of an URL in my AsyncTask: @Override protected String doInBackground(String... args) { HttpURLConnection urlConnection = null; StringBuilder result = new StringBuilder(); try { URL url = new URL(args[0]); urlConnection = (HttpURLConnection) url.openConnection();...
1

votes
1

answer
54

Views

Use DoInBackground Method in a class extending AsyncTask to change Text of TextView in Activity that is not MainActivity

I am an university student programming an android app that shall display messages, which the android device receives via TCP from a server. The class ListenForMessage (extending AsyncTask) opens the TCP connection and receives messages from the server within the DoInBackground method. I can print o...
Peter Sagichnit
1

votes
1

answer
443

Views

Fetch multiple values from firebase database

In our database structure, each 'User' holds multiple bid-Ids, each bid-Id represents an entry point in the 'Jobs' database. Currently when we want to iterate through all jobs of a single person the code looks something similar to: final DatabaseReference mDatabaseJobs = FirebaseDatabase.getInstance...
DsCpp
1

votes
0

answer
35

Views

App crashing from too many Async Tasks

I'm trying to download about 150 images for an application upgrade package. There are in total about 400 files that need to be downloaded from Firebase Storage. I have it mostly set up fine and it's working okay except when it comes to downloading the images which my code submits a huge amount of th...
paul_f
1

votes
2

answer
71

Views

Can AsyncTask be executed from background thread?

While reading the documentation, I found that The AsyncTask class must be loaded on the UI thread. But I am surprised that AsyncTask can also be executed from the worker thread. So the question is: If AsyncTask can also execute from the background thread, Why in the documentation they are saying j...
1

votes
2

answer
507

Views

RecyclerView, adapter, click listener and AsyncTask

I'm facing a issue while trying to implement AsyncTask (to fetch datas from USGS site). I've created an adapter to deal with datas and my recycler view. Before implementing the AsyncTask I had an ArrayList of datas already populated and that worked fine. Now I want to make the request dynamic by fet...
Gilles
1

votes
1

answer
34

Views

Fetch contacts and show simultaneously

I am fetching contacts and this work is going fine. But I am try to also show the contacts in bunch of 50 which is fetched, i.e. user don't have to wait until all contacts has been fetched. I try to with Asynctask , And Thread also but when I go to notify the list adapter then error has came. 'T...
Bhanu Sharma
1

votes
1

answer
223

Views

Xamarin android C# image bitmap load to async, async task

I have some trouble with my project. My works everything fine but when I load the image or multiple image in single gridview in my activity or fragment, it takes 3-5 mins before my activity load. I mean the Android freezes for more than 3 mins before it load the image from the gridview in the activi...
1

votes
1

answer
40

Views

Asynctask not finished downloading before next method call

I have a simple class that extends AsyncTask where I access a textfile on the web and extract content to String tmpString. All this is done in doInBackground(). Right after calling execute(); I call method my own method parseContent(); from another class that extract substrings from tmpString. Now t...
krumpli
1

votes
1

answer
62

Views

back press on a null pointer reference when implemented AsyncTask

I created a file called JoyStickView which extends SurfaceView. In my JoyStickView.java file, I have the following function which calls the AsyncTask to draw two joysticks: private void drawJoystick(float hatX, float hatY) { // Only draw the joystick when SurfaceView has been created if (getHolder(...
frodyteen

View additional questions