Questions tagged [postdelayed]

176 questions
0
votes
2 answers

Handler().postDelayed() sending multiple intents when orientation changes

Ok I'm working on a splash screen that pauses for 1.5 seconds and works great, except for one thing. Once the timer is started in onCreate if the configuration (orientation) changes then the timer gets reset and then end result is it starts my…
JBirdVegas
  • 10,855
  • 2
  • 44
  • 50
0
votes
2 answers

Best practice for delaying program execution in Java (Android)

I am making a quiz app for Android. The user has 30 seconds to answer as many questions as they can. I create a small gap in execution time between questions so the user can see if they got the question right: new Handler().postDelayed(new…
Rob
  • 762
  • 2
  • 21
  • 44
0
votes
1 answer

How to add random seconds delay in function (Android)?

I want to add random delay between 16 to 30 seconds in sending sms in sendSMS Function, I want to know on how to integrate delay for this function and where is the right position to add the seconds delay. Here is Code: private void…
Unswaa20
  • 5
  • 4
0
votes
1 answer

disable button in listener for 1s and generate an output stream after that in android

I'm new in stackoverflow. I created a simple bluetooth app to controll a relay board. The Relay is "on" for 1s after clicking the a button. It works so far but if I click the button during the 1s the relay gets "on" for another 1s. So I want to…
Joe
  • 1
  • 1
0
votes
0 answers

Changing variable inside Runnable postDelayed method

Is it possible to make a runnable postDelayed method changes the value of its variable when running? Because it only loops the initial longitude and latitude that it gets even though the location is changing. So for example there is a new location,…
kencoder
  • 1
  • 2
0
votes
0 answers

Is using a variable as parameter(delaymillis) in Android postDelayed available?

I want to move to another Activity after 5 seconds. (Step4Activity -> WeightActivity) I found this code, and it worked. new Handler().postDelayed(new Runnable() { @Override public void run() { Intent intent =…
Hunter
  • 19
  • 7
0
votes
1 answer

PostDelayed() inside onFinish() in CountDownTimer

I need to use postDelayed() method inside onFinish() method of the CountDownTimer. I use the following code: ... public void onFinish() { Handler handler = new Handler(); handler.postDelayed(new Runnable() { @Override …
Mike087
  • 486
  • 3
  • 13
0
votes
4 answers

How to disable button for 1 sec after clicked in Android?

I am using following code for using a button. I works.(sendBtn is a button in a fragment) sendText = view.findViewById(R.id.send_text); View sendBtn = view.findViewById(R.id.send_btn); sendBtn.setOnClickListener(v ->…
G.ONE
  • 507
  • 1
  • 5
  • 14
0
votes
0 answers

WebView doesn't show the PDF content sometimes using URL

I want to show PDF in a webView . I have a the URL of that PDF . It works at sometimes and shows the PDF but in sometimes doesn't show the PDF when I click on different URL in my RecyclerView . I searched for this Problem and I tries to use…
0
votes
1 answer

Set Handler Postdelayed on Imageview dynamically

I am creating like a Whack a Molee type of game, and I am creating imageviews at random positions on the screen. The thing is, I am adding a postdelayed to a var I am creating every two seconds ( the var is the imageview) but it only acts to the…
0
votes
0 answers

How to execute some code from a function after that function has returned a value in Android?

I'm trying to execute some code defined in a function after that function has executed a return instruction. I'm trying to do it this way: Handler handler=new Handler(); handler.postDelayed(new Runnable() { @Override public void run()…
user2638180
  • 1,013
  • 16
  • 37
0
votes
1 answer

How to get heart rate every x seconds in Android Studio?

I want to get data from the Heart Rate sensor every x seconds. I tried it with postDelayed() but that only works for reading the data every x seconds, but the sensor is running in that time and the battery drains very fast. I'm trying to find a way…
Liviu Pinzaru
  • 37
  • 1
  • 9
0
votes
1 answer

I'm trying to make something like Piano Tiles in android studio and I want the tiles to start coming when play button is pressed with same speed

I'm doing this using handler.postdelayed but whenever i start clicking on tiles postdelayed doesn't work sometimes it comes fast and sometimes slow. Here is the code private Handler mhandler = new Handler(); private Runnable mcontinue = new…
0
votes
1 answer

Stop or Restart Handler.postdelayed

I have a button to show a search bar in my activity and, after ten seconds, I hide the search bar, but if the user presses the button to hide the search bar before 10 seconds, the post-delay must restart or stop below the code used. how do i stop…
0
votes
1 answer

Android Handler.postDelayed only working once

I'm writing a WearOS app that tries to tell the time by vibrating. (e.g. if the time is 4:12 it will vibrate 4 times, then 1 time, then 2 times) I doubt this has much practical use, but I'm doing it as a way to learn about android app…
Oren
  • 84
  • 10