I am working on ibeacon and it is working perfectly fine when app is in foreground or when device is awake but app is in background. The issue is when device goes to sleep mode. iBeacon default methods gets stopped and start working as soon as device awakes. It does not matter whether app is in foreground or background.
I tried wake lock and alarm manager. But failed. Please suggest
I have an android application that uses Geofence and I'm having a hard time overcoming Doze mode. My manifest has the WAKE_LOCK permission and seven setNotificationResponsiveness to 0 for each region. I even changed PendingIntent to BroadcastReceiver but the app literally sleeps or is dead after a while with the deleted smartphone screen. I've already tried using LocationRequest
LocationRequest.setFastestInterval(1000);
LocationRequest.setInterval(2000);
Even so, I did not succeed. Has anyone managed to keep the application running with the Doze?
I faced the issues in My Chatting application and Location Tracking applications, While in doze mode we will not get any push, or we will not get any network connection or location details and most of the background operation will be blocked because of battery optimization, We can solve by 2 ways.
Priority push message(I used in my chatting application) - If you send normal push it will not reach the app until the mobile come to normal, If you send priority push it will reach the app you can do some process within few seconds, but this also have some limitation.
Foreground service, - For your scenario this is the best solution, You should have on service and that service should run as Foreground service so that you can get the Location information all time even in Doze mode.
WAKE_LOCK permission in the manifest is not enough for use a Wake Lock , you need to acquire and release the lock in your code, but starting with Android 6 Doze mode it goes to deep sleep also with an acquired wake_lock.
The way that works for me also with Doze mode :
In the Main Activity onStop I acquire a Partial WakeLock and I start a Service with STARTFOREGROUND_ACTION intent, the Service calls startForeground and shows a Notification.
On Activity onResume the WakeLock is released, the Service stops with STOPFOREGROUND_ACTION intent and the Service itself calls stopForeground & stopSelf.
I ended up putting my application to receive push messages. Apparently the app is no longer being killed by the operating system.
Will the CountDownTimer work when the phone gone to sleep mode? If it doesn't, is there a broadcast receiver which I can detect whether the phone gone to sleep and awake again?
I am trying to create an app where there would be multiple alarm(according to the will of user,so not definite ) but the i am unable to find any assistance. I also my app to run even if the phone is restarted. so in short i want to know about the operations of the usual alarm app that runs in the android phone
You can use a BroadcastReceiver to start your service when your phone restarts. In your service then you can register your alarms.
Here you can find an example:
Autostart Service on Device Boot
How can I make an app respond to ACTION_SCREEN_ON broadcasts even when the app is off?
I have been reading about alarms and IntentService but I am not sure what the best practice is.
I am trying to make an app that takes pictures whenever the screen is unlocked.
Register your BroadcastReceiver in a service.
From Broadcast Receiver within a Service