Questions tagged [android-thread]

147 questions
0
votes
1 answer

Thread.sleep() causes ANR in Android

This code runs on a background Thread: @Override public void run() { while (true) { a = a+1; try { Thread.sleep(100); } catch (Throwable t) { Log.e("","", t); } …
activity
  • 2,653
  • 3
  • 20
  • 44
0
votes
3 answers

How to check and set network status in TextView every 2 seconds?

I want to set network status in TextView, which I want to repetitively call method and set in background, so I used AsyncTask class with infinite loop class setNetworkText extends AsyncTask { @Override protected Object…
Abhishek Sahay
  • 141
  • 1
  • 9
0
votes
0 answers

Android: Thread.sleep() crashes the app

I want to wait time after getActivity().getSupportFragmentManager().popBackStack(); but if I call Thread.sleep or any other solutions to wait time, the app crashes if I wait 1000ms. Instead if I wait 100ms, the app doesn't crashes and I don't know…
Curio
  • 1,331
  • 2
  • 14
  • 34
0
votes
0 answers

What is the authoritative, "proper" way to perform long-running, network operations in an Android app?

I am working on an app that will communicate with a UDP server for its data. Obviously, this is going to be a long-running process (i.e., the life of the activity), so I want to run this process in the background. When the app gets its data from the…
Brian
  • 1,726
  • 2
  • 24
  • 62
0
votes
1 answer

Why a Thread can be started only once?

As for every Android-dummy, also I run into the FATAL EXCEPTION java.lang.IllegalThreadStateException: Thread already started Scrolling forums and questions, I have seen that a Thread cannot be started twice. I have seen answers like these: "It's…
user7867367
0
votes
1 answer

During Incoming Call If I used Thread then App Crash using Plivo SDK and get Fatal signal 6 (SIGABRT), code -6

I am using Service for checking the status of Plivo Login and Handler can perform this action on Service Class and I called service from another Activity. If Incoming call is coming then Immediately App crash. And I get this Error. “A/libc:…
0
votes
1 answer

Is it possible to prevent or restart the main thread when uncaught exception is thrown

I currently have an app which launches a different Activity if the user has crashed multiple times. However, the app can still crash in this alternate activity due to background services / push services. Is there a way to prevent the main thread…
0
votes
0 answers

Android Digital Clock in separate Thread

I've found some video tutorial of Tihomir RAdeff that says how to develop a simple Digital Clock as part of custom View. But it is an example of how to run the Clock drawing in UI thread using Handle and Runnable. Is it a perfect way to develop the…
0
votes
2 answers

Anyway to kill thread/asynctask that run from closed app in android

Is there anyway to kill thread/asynstask from closed android app My app has to kill asynctask before run new asynctask I tried Thread.getAllStackTraces() and check AsyncTask name when app open but I can not kill it. public class MainActivity…
0
votes
1 answer

Password comparing in Android

So I have stored password as hash in shared preferences, when user puts password I need to make a hash of it and compare with stored one. Should it be done in AsyncTask or Thread because calculation and comparison could freeze UI? And then do you…
Zolo
  • 176
  • 1
  • 2
  • 14
0
votes
2 answers

Finish splash screen on website loading

I need to display splash screen until web page is loaded in webview. I use following code. Is it possible to do? public class SplashScreen extends Activity { protected Intent intent; @Override protected void onCreate(Bundle…
NoWar
  • 36,338
  • 80
  • 323
  • 498
-1
votes
1 answer

How to run multiple UI threads in one Activity without ANR?

I want to create a monitoring application and their updated UI every second. for example I have 10 textView for display timing and 10 Progress bar to set some progress to display and 6 timers for display time like a stopwatch. all things in the same…
-1
votes
1 answer

App randomly crashes when starting background thread of a fragment

I have this code for my fragment: public void onViewCreated(@NonNull View view, Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); txtAngle = view.findViewById(R.id.textView_angle); updateTextThread = new…
-1
votes
2 answers

Why not update UI elemnts in Android

In my application i should used socket.io and i want when receive my event update UI elements! I write below codes and i receive my events show me logs, but not update any UI! I want when receive event, check this winner is user or not and then…
Dr.KeyOk
  • 1
  • 4
-1
votes
2 answers

ArrayIndexOutOfBoundsException throws while Thread is working normally

I'm using Thread to set color to a list of ImageView one by one after time of Thread.sleep. It works normally but after few loops of Thread, my app is stop working and throws ArrayIndexOutOfBoundsException. private Runnable runnable = new Runnable()…
1 2 3
9
10