Android Multi-threading is the ability of an Android app to perform work concurrently or asynchronously by utilizing multiple concurrent streams of execution (generally referred to as threads).
Questions tagged [android-threading]
90 questions
1
vote
1 answer
Android ProgressBar not update when insert data to local db
I have a problem with updating progressbar. Here I make a custom progressbar function like below
ProgressDialog progressBar1;
private int progressBarStatus = 0;
private void customProgressBar(){
progressBar1 = new…

Nayan Sarder
- 512
- 1
- 3
- 18
1
vote
1 answer
How to get package name of the library in Android?
I've an android application where I depend on few libraries internally. Now I'm trying to log the crash happening at individual component level (which means individual library level) so that it would help me in analyzing which component is causing…

Tom Taylor
- 3,344
- 2
- 38
- 63
1
vote
3 answers
What is the difference between these methods for running code on UI Thread?
There are different methods posted on the web on how to run code on the UI thread. They all accomplish the same task, however, I really want to know the difference between these methods.
Method 1:
new Handler(Looper.getMainLooper()).post(new…

Mena
- 3,019
- 1
- 25
- 54
1
vote
2 answers
Android WorkManager resending unique task while it is running
I have an android app that needs to perform some long running image processing in the background (processing many chunks of it)
I used a WorkManager to perform the task
I use a user notification to inform of the progress
Versions
API Level…

tishu
- 998
- 15
- 29
1
vote
1 answer
Returning a count of items from Room DB
I am trying to prevent the deletion of a parent from the Room DB if it has children associated by foreign key.
I am working on a degree tracker. If there are courses for a term, the term cannot be deleted. If there are no courses for the term, the…

Matt Spriggs
- 31
- 6
1
vote
1 answer
Using AsyncTask with Runnable vs Creating AsyncTask Class
I recently came across a code snippet that used Runnable with AsyncTask, which I was not familiar with previously.
AsyncTask.execute{
/* Some code to run in Background
* ...
* ...
*/
runOnUiThread{
//run on main thread,…

hasn
- 749
- 6
- 21
1
vote
2 answers
What is the behavior of instance variables passed between threads with AsyncTask?
I understand that it's not safe to access a shared instance variable between multiple threads (unless the variable is declared volatile and properly synchronized). I'm trying to understand the semantics of passing a shared instance variable to a…

Ellen Spertus
- 6,576
- 9
- 50
- 101
1
vote
2 answers
Android Runnable not executed by MainLooper
Brief description of application:
I have Cordova/Ionic application and Custom Cordova plugin for native code execution.
Plugin contains separate CameraActivity (extends FragmentActivity) to work with Camera (parts of code based on Camera2Basic…

Andris
- 1,262
- 1
- 15
- 24
1
vote
0 answers
How to optimize background Tasks in Android
I have app that needs to fetch data from Room Database ( Wrapper for SQLite basically ) every minute to do some checks that data.
I have made implementation with Handler which triggers this async call every minute. Handler is registered on…

Stefan Stejsi Brankovic
- 11
- 1
- 4
1
vote
4 answers
How to show ProgressBar after a certain amount of time
I am working with Android API level 23 (Android 6).
I am using com.loopj.android.http.AsyncHttpClient to implement asynchronous communication with my backend server and it works fine.
While communicating with the server, I am showing a progress…

Thomas
- 620
- 7
- 19
0
votes
2 answers
Thread.sleep on main thread causing view changes to be skipped?
I'm trying to add a red flash to my application when some event occurs.
Using the windowManager, i've created and added a simple view that just fills the canvas with red, and initializes the opacity to 0%
To implement the "flash", I plan to set the…

user3504410
- 173
- 1
- 13
0
votes
1 answer
How would a previously started Thread within a Service be stopped if said Service is killed by the system and later restarted?
If a Service implements a thread, it would hold the reference to it using a class field, so that it could later stop the thread by calling the proper methods (e.g. quit() or quitSafely() in the case of HandlerThread) within onDestroy()…

capalloc
- 23
- 3
0
votes
0 answers
Have race condition saving items into a Room database
I am trying to save the following dao object into a Room database -->
data class JobPW(
@Embedded val job: Job,
@Relation(
parentColumn = "job_id",
entityColumn = "worker_id",
associateBy =…

user1743524
- 655
- 1
- 7
- 14
0
votes
0 answers
How to display the bitmap on ImageView "again" via Thread in Android
I am trying to display the bitmap that was created from PreviewView of Camera. It can only display once to the other android if I close the outputStream but it will close the whole socket as a result. Therefore, I can't display the next image.
Here…

strygel
- 1
- 2
0
votes
0 answers
Handling configuration changes when there is a background thread running - Android
I have a fragment that launches a background thread to do some work and uses a handler callback to update some UI when the thread finishes its task.
public class CodeFragment extends Fragment implements View.OnClickListener, Handler.Callback {
…

Sandeep Tadepalli
- 76
- 8