TheLastProject / RaiseToAnswer

Simply hold your phone to your ear to answer an incoming call
https://play.google.com/store/apps/details?id=me.hackerchick.raisetoanswer
MIT License
74 stars 13 forks source link

Start service after update and reboot #2

Closed TheLastProject closed 4 years ago

TheLastProject commented 4 years ago

Will have to decouple starting the service from the main activity and do something with the following intents:

<action android:name="android.intent.action.MY_PACKAGE_REPLACED" />
<action android:name="android.intent.action.BOOT_COMPLETED" />

It will seriously improve the user experience if users won't have to restart the app after updates or reboots, but this seems to need a serious refactor and messing with parts of Android I have no experience with.

gabsoftware commented 4 years ago

Would that mean that the notification wouldn't be necessary? Personally I don't like apps that add icons in the status bar and permanent notifications. I understand that this is a probably a way of circumventing battery optimizations so that the app is not closed automatically. However I wish that there would be another way than having a permanent notification.

TheLastProject commented 4 years ago

The notification will still be necessary. Recent Android versions will not allow any background service to read sensor data and to be a foreground service one needs to have a permanent notification. I'm not a huge fan of it either but it isn't avoidable due to Android limitations. The most that could be done is only show the notification while their is an incoming call

gabsoftware commented 4 years ago

The notification will still be necessary. Recent Android versions will not allow any background service to read sensor data and to be a foreground service one needs to have a permanent notification. I'm not a huge fan of it either but it isn't avoidable due to Android limitations. The most that could be done is only show the notification while their is an incoming call

That would be a good compromise!

TheLastProject commented 4 years ago

I moved a lot of code around so that no activity is needed to start all the things anymore. Everything can be started from a broadcast intent now, so we no longer need an always listening service.

I've confirmed that the app works fine after a reboot (although it may take a minute to start working after a reboot because Android is slow) so I think it will likely survive an update now too (but how does one test this?!)

So, I consider this fixed in https://github.com/TheLastProject/RaiseToAnswer/commit/38dddd6f671660e12e8da1a0b4d4a8e34e38496f.