Skip to content

Commit e55ff09

Browse files
author
WhalenSun
committed
对registerReceiver加上Android12版本的判断
1 parent 6cc3689 commit e55ff09

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

hub/hub-device-android/src/main/java/com/tencent/iot/hub/device/android/core/mqtt/TXAlarmPingSender.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,11 @@ public void start() {
6666
String action = TAG + TXMqttConstants.PING_SENDER + mComms.getClient().getClientId();
6767
TXLog.d(TAG, "Register alarmreceiver to Context " + action);
6868
if (mContext != null && mAlarmReceiver != null) {
69-
mContext.registerReceiver(mAlarmReceiver, new IntentFilter(action), RECEIVER_NOT_EXPORTED);
69+
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.S) {
70+
mContext.registerReceiver(mAlarmReceiver, new IntentFilter(action), RECEIVER_NOT_EXPORTED);
71+
} else {
72+
mContext.registerReceiver(mAlarmReceiver, new IntentFilter(action));
73+
}
7074
}
7175

7276
int flags = PendingIntent.FLAG_UPDATE_CURRENT;

0 commit comments

Comments
 (0)