• Srabanti Chakrabarty

The third part of Aviraj's journey


Even though background services is what it’s called, it plays one of the most foremost roles in any application that a developer creates, whether it be from a developer's point of view or whether it be from a user’s point of view.

What is so important in a service? Service is a component that runs in the background, without direct interaction with the user. Agreeing to the point that the main objective of a background service is basically to perform operations at the background which does not require user interaction (BLE scanning in our case), I had my ups and downs in the implementation of the same. Like the application was getting terminated by the Task manager every time an attempt was made to search for nearby BLE devices. Also, the application was not able to upload the collected data to the cloud. But these missing pieces of the puzzle were completed by some temporary solutions. For the termination issue, the Android Services and WAKE_LOCK function was used which kept the app running even when the device would be in sleep mode.

It was not much till here, the application was still not able to scan the nearby BLE devices in the background though it was working fine for sleep mode. I started looking for solutions online and came across a webinar with Niharika Arora (Senior Software Engineer at 1mg), she is a contributor to the Aarogya Setu Application. She conducted the webinar for the explanation of the functionality of the Aarogya Setu application and that’s where I could find resemblances in the structure of Aarogya Setu and the BLE Device application. The knowledge that she passed on to us in the Webinar proved extremely useful and I put it to use in my application with Researchime and implemented a solution for 30 minutes BLE timeout the same way that it's done in the Aarogya Setu application. I also learned a few other things such as Adaptive Scanning (i.e Scanning according to the number of data packets near the router). She also helped me understand how different OEM’s may affect the BLE Adapter. Thank You Niharika!

“The Best Teacher is your last Mistake” and yes I did make mistakes, learned from a few but I also had my mentor to the rescue, to reverse the mistakes to the rights, and bring the best out of me. For instance, when I was developing a new instance of BLE Adapter every 40 seconds, the Android Task Manager used to kill the processes every single time, as the CPU would have an unnecessary load while running the processes every 40 sec. But my mentor, Shashanka Ashilli pointed out the mistake I was doing and helped me to mold the process in the right way by putting the BLE Adapter in use for 1 minute in the frequency of 15 minutes. This helped reduce the CPU Load and then the processes ran perfectly.

“Knowledge has no bounds and so does Learning”. The application in now working fine in Sleep Mode with some minor changes. Now I’m onto learning more about Background Services which still needs to be done.

Aviraj Singh

Lead- Software Engineer

© 2020 Researchime

Developed by FiCity

  • Black LinkedIn Icon