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);
}

posted on 2024-07-25 09:21  陈德彪  阅读(11)  评论(0编辑  收藏  举报

导航