The pedometer application developed previously will be renovated, and we are investigating the required impact of the target SDK starting this November on Android 8 or higher.
Currently, we count the number of steps as a service.The number of steps is counted even if the application is not started.
The service started with startService() at the following time:
·When starting the application
·When starting the terminal (RECEIVE_BOOT_COMPLETED)
·Application update (PACKAGE_REPLACED)
I would like to support Android 8, but I can't try it because I don't have an actual Android 8.
What should I do to make Android 8 work without any problems?
Thank you for your advice.
Selfless.
I was able to get the Android 8 terminal and confirm that it works with the following changes.It was simpler than I expected.
Changed service startup to:
ContextCompat.startForegroundService(this,newIntent(this,PedometerService.class)));
Performed the following in service onCreate.
if(Build.VERSION.SDK_INT>=Build.VERSION_CODES.O)
startForeground (1, new NotificationCompat.Builder(this).build());
© 2024 OneMinuteCode. All rights reserved.