Questions tagged [android-timer]
70 questions
0
votes
1 answer
Local alarm for a foreground service?
I have a foreground service and while it's active I want to run some events based on specific exact time that you a user previously set, it can be one time or it can repetitive every day for example.
I don't want to use AlarmManager because it…

user924
- 8,146
- 7
- 57
- 139
0
votes
1 answer
Cancel CountDownTimer when its activity coroutine job is cancelled
I have coroutine scope assigned to an activity lifecycle like this
class MainActivity : AppCompatActivity(),
CoroutineScope
{
override val coroutineContext: CoroutineContext =
Dispatchers.Main + SupervisorJob()
...
…

yaugenka
- 2,602
- 2
- 22
- 41
0
votes
3 answers
How can I use a Timer of 2 seconds inside a fragment?
This is my Fragment.kt
class SplashFragment : Fragment() {
override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
return…

Rishabh Mehta
- 427
- 3
- 2
0
votes
1 answer
Android Application code stop when phone screen is locked
I've coded the app that check the conditions for every minute in background and if it true then it will send notification/vibrate.
It works fine, but only when my phone is active (means the screen is not locked).
I've tried many solutions like using…

Tsu
- 15
- 5
0
votes
3 answers
How to disable view ( Button ) for specific time period (for example 5 seconds ) every time user click on button in android studio in kotlin?
When user click on the button (button is home activity) he will intent to game activity in 30 sec to 1 min user may win or lose and come back to home activity and then button must get disabled for 3 min (with time countdown showing) after 3 min…

Naman
- 28
- 4
0
votes
1 answer
Android Notification is not Showing Java for Stop Watch
It's me again, and now I'm currently building an app for a stopwatch, alarm, etc.
So I've added service and notification into my code but the thing is that the only one which runs perfectly is the main view or simply I called it "TimePlayer.java",…

XVallerie
- 141
- 2
- 11
0
votes
1 answer
IllegalStateException error in android fragment
I am using CountDownTimer in fragment
Sometimes onFinish () throws an error
Attach error messages and error codes
public void onFinish()
{
btnTimerStart.setText(getString(R.string.btn_restart));
timer_display.setTextSize(45);
…

leegill
- 111
- 2
- 10
0
votes
1 answer
CountdownTimer is not working as intended (wrong time)
I'm using CountdownTimer in my app to display remaining time until specific Date. But Date is only 2 hours from current time, but if I convert millisUntilFinished to hours, it says 9 hours. Date is in UTC format.
remainingTimer = object :…

martin1337
- 2,384
- 6
- 38
- 85
0
votes
1 answer
Whats the Best approach to show an alert dialog every 5 minutes ,after a view /activity/frag is visible?
I am planning to implement a timer in my app such that only specific activities will have it, say I have 2 activities,1 fragment with this.
When I move to activity 1, the timer starts and if I am still on the same view after 5 minutes, it should…
user2386226
0
votes
4 answers
Close an activity after a defined time period
I want to start an activity and store the start time in a variable, suppose session variable and check every second for a duration of 30 minutes. The moment it elapses 30 minutes the activity will close.

user3099225
- 413
- 1
- 4
- 14
0
votes
0 answers
Code set to run during a timer is being triggered intermittently
I have a countdown timer that runs when a user presses a button, at the conclusion of the timer, the location of the device is sent to another device for which the user enters a phone number for. Here is my timer code::
private void initTimer()…

user3717503
- 23
- 6
0
votes
1 answer
TimerTask for Reconnecting in splash screen
I have splashScreen with some startup requests where data are loaded into the app. Before I initiate those splashScreen requests, I want to check connection. This part is working fine, but if app doesn't have access to the internet, I want to check…

martin1337
- 2,384
- 6
- 38
- 85
0
votes
0 answers
Android Webview redirecting after x seconds
So i'm trying to redirect from a webview to another activity after X seconds. The problem is that the new activity is launched two times for some reason..
any solutions? Sample code below.
myWebView.setWebViewClient(new WebViewClient() {
…

Toby
- 53
- 7
0
votes
0 answers
Android: Handler and Timer inside a RecyclerView is not working properly
In a chatting window I have a feature like self destructing message after a duration. For which I have a class which shows burning animation after the duration. While sending text the handler and timer I used in the below class is working fine for…

Zim
- 182
- 1
- 1
- 10
0
votes
0 answers
How to keep Chronometer running on Listview after back is pressed or App has been closed?
I managed to add a chronometer on ListView with a start and stop button and all are working fine, but when I press back or I close the application Chronometer values are reset to 00:00. I need to let it continuing counting even if the app is closed…

Alexis MUGWANEZA
- 69
- 10