Skip to content

Commit

Permalink
对registerReceiver加上Android12版本的判断
Browse files Browse the repository at this point in the history
  • Loading branch information
WhalenSun committed Jun 7, 2024
1 parent 6cc3689 commit e55ff09
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,11 @@ public void start() {
String action = TAG + TXMqttConstants.PING_SENDER + mComms.getClient().getClientId();
TXLog.d(TAG, "Register alarmreceiver to Context " + action);
if (mContext != null && mAlarmReceiver != null) {
mContext.registerReceiver(mAlarmReceiver, new IntentFilter(action), RECEIVER_NOT_EXPORTED);
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.S) {
mContext.registerReceiver(mAlarmReceiver, new IntentFilter(action), RECEIVER_NOT_EXPORTED);
} else {
mContext.registerReceiver(mAlarmReceiver, new IntentFilter(action));
}
}

int flags = PendingIntent.FLAG_UPDATE_CURRENT;
Expand Down

0 comments on commit e55ff09

Please sign in to comment.