Making a CountDownTimer not pause when activity is paused/backgrounded - Kotlin - kotlin

I'm making an app in Android Studio that includes a CountDownTimer in MainActivity. I have some other activites to show other stuff but when I start the other activities, the CountDownTimer in MainActivity pauses. I need it to keep counting, how can I do that?
I haven't tried anything because I couldn't find any suitable solution to my problem and I'm not a Kotlin expert either.

Related

React Native - Execute code in background on specific battery percentage

I have a react native application where the user can choose any battery level from 15 to 100. When his battery reaches the chosen value, javascript code should be executed.
Is there a way to do this when the app is in the background? I am aware I can have long running tasks, which will be displayed as a notification to the user and I can have my code logic there.
Are there any alternatives that do not include long running tasks?
My solution for this problem to register a BroadcastReceiver in android, which will be executed every time when the battery percentage changes. It works in background and if the battery reaches a certain threshhold, a headless task can be executed which will run javascript code.

How can I move from one fragment to another fragment on button click? (kotlin)

I’m trying to move from one fragment to another fragment on button click and I have watched tutorials on YouTube using ViewBinding to perform this action. But each time I try, it just doesn’t seem to work. I have added the “build features{
ViewBinding true “ in my Gradle (module:app) file and each time I run my app, my app crashes with the error “unknown host: ‘dl.google.com’”
PS: findViewById doesn’t work in fragments
I have spent weeks trying to figure this out. Can someone pls help me out?
Thanks in Advance
Moving from one fragment to another can be easily achieved using Navigation component.
I would suggest taking a look at this link as a starting point:
https://developer.android.com/guide/navigation/navigation-getting-started

Using Expo React Native, is there any way to run a stopwatch / timer in the background?

Problem
I've created a simple stopwatch app using Expo for React Native. When I leave the app (click the home button on iPhone), and return to the app, the stopwatch starts back up from the time when I left. For example, if the stopwatch is at 3 seconds and I leave the app for 5 seconds, when I return it is still at 3 seconds rather than 8.
Question
Using Expo, is there any way to run the stopwatch in the background? If yes, how? If no, what is the best workaround?
Resources
I've found similar questions that are dated, but I'm looking for something recent. Some of the resources mentioned in the other answers are the following:
https://docs.expo.io/versions/v35.0.0/sdk/background-fetch/
https://github.com/ocetnik/react-native-background-timer
It sounds like your best bet is to note the start time and persist it, e.g. using Expo's AsyncStorage. Then you can just display the time elapsed since this stored start time.

gpus_ReturnNotPermittedKillClient while app is being "backgrounded"

I have an (old) audio app that is misbehaving on iOS 5.1.1. It records audio and on older iOS versions (don't know precisely where the "break" is) it would stay "in foreground" while recording, without any nudging.
But on 5.1.1 the app is put into background after two minutes, and then things go sour. Currently (will have to change this, I suppose) the app kills recording when it's backgrounded (and it appears to do this successfully), but it still dies with a trap in the above routine.
Unfortunately, the call stack is empty when this occurs, so there's little clue as to why the app's getting killed, but I gather (just from hints here and there on the web) that the trap occurs because a background app cannot use any UI facilities, and the app must somehow be calling something UI-ish. But I haven't a clue what it might be.
I've worked through most of the notifications, to see if a notification might be lurking in a queue somewhere and doing something, but I've not found anything so far that might be triggering a UI opp.
Any ideas on how to track this down?
Aha!! The app uses an Apple freebee widget known as AQLevelMeter. When recording is stopped, the level meter is also stopped, but the stop code inside AQLevelMeter.mm does not invalidate the timer that's driving the UI updates.

How to detect whether my app is loading data, and if so, showing a loading screen

I want to implement into my cocos2d project (ipad) a loading screen, whenever data is being fetched. Is there a convenient way to do this without hard-coding it ?
Add a flag/start an activity indicator/etc. that indicates that the loading has begun at the beginning of the computational process and stop it after the end. Update in the meantime if you intend to add a progress bar.
Check out this github project. It gives you a framework for detecting when a task that you want to happen is in progress. It also lets you decide what happens when the task is completed.