Skip to content

Commit 0c19bab

Browse files
author
WhalenSun
committed
修复targetSDK为34时,因动态注册 Broadcast Receiver 未声明flag引起的crash
1 parent b5cd3ac commit 0c19bab

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

hub/hub-device-android/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@ apply plugin: 'signing'
44

55

66
android {
7-
compileSdkVersion 31
7+
compileSdkVersion 34
88
buildToolsVersion "26.0.3"
99

1010
defaultConfig {
1111
minSdkVersion 16
12-
targetSdkVersion 31
12+
targetSdkVersion 34
1313
versionCode 2
1414
versionName "1.1"
1515

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package com.tencent.iot.hub.device.android.core.mqtt;
22

3+
import static android.content.Context.RECEIVER_NOT_EXPORTED;
4+
35
import android.annotation.SuppressLint;
46
import android.app.AlarmManager;
57
import android.app.PendingIntent;
@@ -64,7 +66,7 @@ public void start() {
6466
String action = TAG + TXMqttConstants.PING_SENDER + mComms.getClient().getClientId();
6567
TXLog.d(TAG, "Register alarmreceiver to Context " + action);
6668
if (mContext != null && mAlarmReceiver != null) {
67-
mContext.registerReceiver(mAlarmReceiver, new IntentFilter(action));
69+
mContext.registerReceiver(mAlarmReceiver, new IntentFilter(action), RECEIVER_NOT_EXPORTED);
6870
}
6971

7072
int flags = PendingIntent.FLAG_UPDATE_CURRENT;

0 commit comments

Comments
 (0)