Turn on/off flashlight while app is minimized - android

In my application I have an activity and a service. The service continously manages some data. In certain cases the service sends a broadcast request to the activity to turn on flashlight.
This works very well. However it does not work when app is minimized (manually or by incomming call). As soon as I bring the app back to the front it starts to work again.
As I observed the log I saw that the service is still running when app is minimized. However since the activity is not present anymore the camera object cannot be accessed to activate the flashlight. But there is no error in the log.
Why is the flashlight not activated? How can the flashlight be activated when the app is minimized?

Only the foreground activity can hold the camera. From the Google documentation:
"If your application does not properly release the camera, all subsequent attempts to access the camera, including those by your own application, will fail and may cause your or other applications to be shut down."
You can try claiming it on the service instead, but I suspect that won't work well. It just really wasn't designed to work this way.

Related

How to Start forced stop application after phone reboot

I was trying to get to know about the possibilities of getting success of Starting up a forced stop application after the phone reboots. So here is the scenario:
My app will not have any activity. It will be a service only app where no activity will be declared. So my goal is when ever the phone restarts, it will start up the service automatically even though the service is force stopped before the phone reboots. I am using Google Pixel 6 with Android 12 rooted phone. So I have all the necessary permission to achieve the task. I have tried couple of examples from stackoverflow. none of them works. They works only if you keep running the app before the phone reboots. It wont work if the service is Forced stop before the phone restarts. Any help will be appreciated.

Audio Call Stops working when Android App goes in Background and device is on Battery Saver Mode

My question is more like client side.
I am using Janus AudioBridge Room to make audio call.
Android app works fine in foreground and background mode if device is not on Batter saver mode.
But when device is in Battery saver mode. App gets hold while getting into background.
When we gets back to the app. Call rejoins from there. But if it gets long enough to call 'Keepalive' event. Then app will stops or crash.
I handle this by getting this android permission explicitly from user.
"android.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS"
Then in battery saver mode. our call does not affects. as our app now can work on background in battery saver mode also.
I don't think this is the best way to do that.
I checked Whatsapp permissions. They are not asking for it.
What Whatsapp or other calling applications are doing to do this in a more proficient way?
Any guide and Clue will be helpful. I appreciate

How can I keep a BLE app alive all the time?

I'm trying to connect an App to a custom system with BLE that I added to my dog's door, which allows me to open/close it remotely as well as to know when is open "illegally" so it reproduce an alarm in my phone.
I've added the BLE class to the Main Activity and manage it from there, using fragments to see the data and sending commands.
But the problem I'm having is that, after some time, the App just close itself, breaking the BLE connection so I can't receive updates in "real time".
I don't know if is possible that the system don't kill the App, I've hear about services and that they keep the connection alive, but I'm not sure if they respect the other parts of the App or if the App get killed but the service don't. I've never worked with services before.
I've added the REQUEST_IGNORE_BATTERY_OPTIMIZATIONS permission and also disabled the memory optimization as well but it still get killed.
When the app is killed and I press the App icon to open it, it looks like a fresh start and it should be keep alive all the time. Otherwise I will have "security issues" if something happens while I'm not connected.

Started Service stops if application is forcestop from download App

i made a sample android app,which starts a started service by calling startService(serviceintent).
it works fine,but if i forceQuit my application from settings>app>downloaded>force_Quit.my service stops and even destroyed is not called.
i studied for 3-4 days and know about start_sticky in StartOnCommand method.i am able to achieve all aspects of service.
I want to know whatever i am achieving that service stops and doesnot restart automatically even if started as Start_Sticky is normal behaviour according to android.Can i make it restared if user force quit my application.
my manifest is correct i uses process tag also.
if i forceQuit my application from settings>app>downloaded>force_Quit.my service stops and even destroyed is not called.
Correct.
Can i make it restared if user force quit my application.
No. Nothing of your app will run again until something uses an explicit Intent to start one of your components. Usually, that means that the user taps on your icon in the home screen launcher, though there are other explicit-Intent scenarios (e.g., GCM message).

Does android keep a log of when it starts?

I'm making a parental control/accountability app for android. It consists of a monitoring service that runs in the background and starts when the phone is booted.
Unfortunately, I have found that when android is started in "Safe Mode", services are not started automatically, and because of this my app has a serious flaw.
While in safe mode, the web and other apps can be started without my monitoring service running.
I thought that if it isn't possible to monitor app activity while in safe mode, maybe I could at least have my app detect if the phone was previously in safe mode. Then it could maybe alert the parent or accountability partner?
Does Android keep any log of this? Or any boot log in general?

Categories

Resources