Questions tagged [android-thread]
147 questions
241
votes
12 answers
Repeat a task with a time delay?
I have a variable in my code say it is "status".
I want to display some text in the application depending on this variable value. This has to be done with a specific time delay.
It's like,
Check status variable value
Display some text
Wait for 10…

Kalpa Pathum Welivitigoda
- 2,411
- 3
- 15
- 3
75
votes
4 answers
When to use handler.post() & when to new Thread()
I'm wondering when should I use handler.post(runnable); and when should I use
new Thread(runnable).start();
It is mentioned in developers documentation for Handler:
Causes the Runnable r to be added to the message queue. The runnable
will be run…

reiley
- 3,759
- 12
- 58
- 114
25
votes
7 answers
How can I perform LiveData transformations on a background thread?
I have a need to transform one type of data, returned by a LiveData object, into another form on a background thread to prevent UI lag.
In my specific case, I have:
MyDBRow objects (POJOs consisting of primitive longs and Strings);
a Room DAO…

Alex Peters
- 2,601
- 1
- 22
- 29
9
votes
2 answers
How can CoroutineScope(job+Dispatchers.Main) run on the main/UI thread?
If the operations inside CoroutineScope(job+Dispatchers.Main){...} run on the main thread then how come it does not violate Android's requirement that slow (blocking) operations (Networking etc.) are not allowed to run on the main/UI thread? I can…

372
- 237
- 2
- 10
9
votes
0 answers
How to properly rotate Android device with GLSurfaceView while containing OpenGL context and GL thread?
I have a simple Android application that renders data with our OpenGL rendering SDK to an Android GLSurfaceView. Since we provide and SDK for others to use we need to support all use cases for the GLSurfaceViews. Currently we need to be able to…

Krøllebølle
- 2,878
- 6
- 54
- 79
8
votes
2 answers
Does PagingData Run on a Background Thread by Default in Paging 3 Library?
Is background threading managed automatically with PagingData as it is with PagedList, and then returned on the main thread?
From the logs below, it appears PagingData is not run on the backgroud thread in the Paging 3 library compared to PagedList…

AdamHurwitz
- 9,758
- 10
- 72
- 134
7
votes
0 answers
how to debug long monitor contention on android
I don't know exactly what change I did on the code that made my app SUPER SLOW, now it takes about two minutes to start but before it would take less than 30 seconds.
I'm getting hundreds of messages like this just starting the app which no real…

Rafael Lima
- 3,079
- 3
- 41
- 105
6
votes
1 answer
Run standalone Completable on background thread
I am trying to create a completable and run it on background thread but it's not calling Action's run() when I am subscribing on Schedulers.io()
Basically I want to do following through RxAndroid:
Thread t = new Thread(new Runnable() {
…

user1288005
- 890
- 2
- 16
- 36
5
votes
0 answers
Received exception on GL render thread : android
I'm using CAMERA2 API and meanwhile developing an application without any errors the application will run superbly. But after recording some chunks of clips it shows above mentioned error.
This is my approach,
1.Open the camera using cameraManager…

E J Chathuranga
- 927
- 12
- 27
4
votes
1 answer
pytube takes too long to stream a video in Android
I am using pytube to stream a video in Android, with the help of chaquopy.
videofile.py
from pytube import YouTube
def video(link):
yt = YouTube(f'https://www.youtube.com/watch?v=' + link)
stream_url =…

George
- 255
- 8
4
votes
3 answers
how to stop open activity while splash screen killed
I have splash screen .
once i open my application the splash screen will appears after completion of splash screen passed intent to HomeActivity.
but when i kill this app while splash screen running after some time HomeScreen will automatically…

PRP
- 101
- 9
4
votes
1 answer
How to properly approach threading with Room
I am confused about Room and can not find an answer in the documentation.
So, the library enforces using queries on a separate Thread, which is understandable. However, it seems that Delete queries are not included in this limitation and can be…

Kelevandos
- 7,024
- 2
- 29
- 46
4
votes
3 answers
Android: Realm access from incorrect thread. Realm objects can only be accessed on the thread they were created
So inside a IntentService, the app maybe active or inactive , onHandleIntent gets called , where I have placed this below code.This is where I store the data into realm.
Realm realm = null;
try {
realm = Realm.getDefaultInstance();
…

MrRobot9
- 2,402
- 4
- 31
- 68
3
votes
1 answer
Android Thread Execution Slows Down when screen locks
Iam running this procedure to download some data and insert them into the database. The total procedure takes around 5 minutes. I noticed that while downloading, when the phone locks the screen and open it after 5 minutes, it will still downloading.…

Nick
- 2,818
- 5
- 42
- 60
3
votes
2 answers
Show an Alert Dialog in onMessageReceived - FCM
I am trying to show an alert message in onMessageReceived of the MyFirebaseMessagingService class and I get an error:
java.lang.RuntimeException: Can't create handler inside thread that has not called Looper.prepare()
…

BRDroid
- 3,920
- 8
- 65
- 143