Skip to content

Commit

Permalink
修复targetSDK为34时,因动态注册 Broadcast Receiver 未声明flag引起的crash
Browse files Browse the repository at this point in the history
  • Loading branch information
WhalenSun committed Jun 6, 2024
1 parent fa16787 commit 6cc3689
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
4 changes: 2 additions & 2 deletions hub/hub-device-android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ apply plugin: 'signing'


android {
compileSdkVersion 31
compileSdkVersion 34
buildToolsVersion "26.0.3"

defaultConfig {
minSdkVersion 16
targetSdkVersion 31
targetSdkVersion 34
versionCode 2
versionName "1.1"

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.tencent.iot.hub.device.android.core.mqtt;

import static android.content.Context.RECEIVER_NOT_EXPORTED;

import android.annotation.SuppressLint;
import android.app.AlarmManager;
import android.app.PendingIntent;
Expand Down Expand Up @@ -64,7 +66,7 @@ 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));
mContext.registerReceiver(mAlarmReceiver, new IntentFilter(action), RECEIVER_NOT_EXPORTED);
}

int flags = PendingIntent.FLAG_UPDATE_CURRENT;
Expand Down

0 comments on commit 6cc3689

Please sign in to comment.