How do you go about detecting what app is currently running on the foreground when using react-native.
My RN app will be running in the background and needs to be able to detect the launch of specific apps within the phone. For example if the user opens game, how would i go about detecting what the app opened is (app package id).
I read that android native has this feature, through reading this stack overflow question detect apps running in foreground
I would like to know if there is a process similar in react-native, help would be much appreciated.
Thanks.
Related
I have created a calling application group/p2p using peerjs in react native. Everything works fine when app is in foreground. But if the scree black out due to proximity or screen lock and goes to background, voice is disconnecting after few seconds. Searched good and gone though the Android documentation for the solution. But could able to find any appropriate answers. Due to latest changes in Android 11, access of microphone & camera in background is limited. I don't know how to achieve this. Can someone please point me to right direction. I'm new to react native and mobile development. Thanks in advance for help.
I want to create an android app that runs on a specific device (tablet). But i do not really know how i can make sure the user (me, my friends and family) not exit the application and not even notice it is running on android.
I know that by running your app in "Kiosk mode" your app will open right after starting up the device. But is there a way to hide the lock screen, nav and notification bar. I would like not to see battery and wifi icons and would like to hide all the notifications when using the app.
basically when i am using the app i want to have the same experience as i have when i use a google home hub. There is no way to exit the application or tamper with the device without knowing how and there is no way to even discover it is running Android. As far as the user is concerned the device is running the app as OS.
Is there any way to get this experience?
PS: i'm a student so i will not be able to pay for any software i would like to use opensource resources or code it myself.
Thanks for the help in advance. :)
Have searched for solution but none has worked as i want.
Am developing a app for personal usage and want to control MediaPlayer from it, while application is in background. Is it possible and if so, how to achieve that ? Targeting Android 6.0+ and to control Spotify
Currently I'm only able to do that in a Rooted phone with exec command input keycode but on unrooted phone this only works while app is in foreground.
Found the best working example here:Control Spotify
Works great on A7.1.1
However when Spotify I brought to front, it's state is reset to home-screen.
I've read all the questions related to quitting Android application. But I could not find the answer to my problem.
So what is my problem. My application is a music player written in Qt (C++/QML). I wrote it especially for my car. First it was a UMPC with Windows, now I have an aftermarket headunit with Android. I successfully ported my player to Android.
Now I try to solve following issue. If I shut off my car, the Android "computer" inside my radio also shuts down. I would like to save the current track and the track progress so I can resume it on next start.
Is it possible to catch the signal from Android that my app should close and save the settings? Or does Android kill my application without giving me a chance to react to it?
Currently I'm saving the progress to a database every 10 seconds. But I feel this not ideal. I would like to know how applications are closed in Android in these situations:
1) The app is in background and OS decides it needs more RAM and terminates it
2) User invokes app switching menu a swipes my application away
3) System shuts down
4) A "battery saver" (task killer) closes my application
Can I react on some of these situations and do something before my app is closed.
If you use ApplicationWindow (you mention you are using QML so you should be using that) it is trivial:
onClosing: {
saveYourSettings()
close.accepted = true
}
I have an application and I would like to block the exit of it to the people that doesn't know the application,
how can i do it?
I only found a function to block back button...
Thank you so much...
The closest thing I could find is called task locking or screen pinning on Android. It is only supported on Android Lollipop (5.0) or higher. The documentation has the following to say about this feature:
Android 5.0 introduces a new screen pinning API that lets you
temporarily restrict users from leaving your task or being interrupted
by notifications. This could be used, for example, if you are
developing an education app to support high stakes assessment
requirements on Android, or a single-purpose or kiosk application.
Once your app activates screen pinning, users cannot see
notifications, access other apps, or return to the home screen, until
your app exits the mode.
There are some other questions asked regarding task locking, which you can find here and here.
I have been able to find a Cordova plugin for this here, however it doesn't seem to be very active at this moment in time.
Unfortunately, I don't think that this will actually solve your problem. From what I have been able (or unable) to find, this just doesn't seem to be possible. I think it is similar to closing an app on iOS with code, it is simply not allowed by the developers of the operating system.