Recently i was involved in android dev..So im gona share a short struggle in android services.

Why

So i was targeting android 5.1 and the basic feature was setting up and do some action for every % minutes, so this varies.. below 6.0 everything was fine and was working flawlessly but i was testing it on a mobile with android 6.1.

Doze

Since the new android versions comes with android doze enabled, and every manufacturer has their own implementation of doze enabled with custom implementations starting from android 6.0 setting up tasks was a teadious task if you are not familiar with android… so what does doze do to your mobile.. it puts your mobile to a power save state with low cpu frequency and waking it up only at certain intervals for notifications and stuff this conserves a lot of battery and enforces strict policy on the apps and clears any upcoming tasks setup by the apps.

Services

So my problem statement was explained in the why seciton of this post… so the solution to this was setting up a custom service but thats not feasible because of the doze implementation.

nowadays most android devs focus only for dev of android 5.0/5.1 above. ‘apart from the sincere android devs who still check for backward compatability for each and every single feature..’

  Coming to the point android 5.0 above introduced a new feature called job scheduler that reduces the work of the devs by setting up and impementing in several differnet ways.. so thsese can be

  • alarm manager
  • firebase jobdispatcher
  • sync adapter
  • other facilities etc..

so if incase anymethods fails it implements it other methods… this all works on upuntil 6.0 but because of the doze feature the limit is set to 15 min.. so pretty much its a dead end… only possible way custom service with notification to prevent doze feature, if destroyed create it again with the job close event trigger and remove previous values set by job scheduler. Apart from this there are several dependenscies, with differnt types of implementation..literally there are tons of implemenations to the same one..its a rabbit hole where if you focus on one thing it goes on and on, deeper and deeper… do a lot of freakin research…but it takes time which i dont have..what should I do?.. in the middle lot of third party libraray if you  just want to learn something from scratch its just soo hard… maybe its just a rant or maybe not… anyway do try your best..and give a try.

android dev = mess of libraries and confusion on what to choose for dev..

forgot to mention if you want to implement a new feature..literally there are 100s of methods to do them.