Targeting S+ (version 31 and above) requires that one of FLAG_IMMUTABLE...
将
PendingIntent tPendingIntent = PendingIntent.getBroadcast(context, 2, hardwareStepCounterServiceIntent, 0);
修改为
PendingIntent tPendingIntent = null;
if(android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.S)
{
tPendingIntent = PendingIntent.getBroadcast(context, 2, hardwareStepCounterServiceIntent, PendingIntent.FLAG_IMMUTABLE);
}
else
{
tPendingIntent = PendingIntent.getBroadcast(context, 2, hardwareStepCounterServiceIntent, 0);
}