diff --git a/app/src/main/java/com/huawei/hms/awareness/codelab/awareness/barrier/BluetoothBarrierActivity.java b/app/src/main/java/com/huawei/hms/awareness/codelab/awareness/barrier/BluetoothBarrierActivity.java index 56a02e2e2f6ae8f6635632a4cda2e4c3783aab45..80b281378f87d7e094c9d2730b9030a9d3967a38 100644 --- a/app/src/main/java/com/huawei/hms/awareness/codelab/awareness/barrier/BluetoothBarrierActivity.java +++ b/app/src/main/java/com/huawei/hms/awareness/codelab/awareness/barrier/BluetoothBarrierActivity.java @@ -55,7 +55,7 @@ public class BluetoothBarrierActivity extends AppCompatActivity implements View. Intent intent = new Intent(barrierReceiverAction); // You can also create PendingIntent with getActivity() or getService(). // This depends on what action you want Awareness Kit to trigger when the barrier status changes. - mPendingIntent = PendingIntent.getBroadcast(this, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT); + mPendingIntent = PendingIntent.getBroadcast(this, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_MUTABLE); // Register a broadcast receiver to receive the broadcast sent by Awareness Kit when the barrier status changes. mBarrierReceiver = new BluetoothBarrierReceiver(); @@ -113,6 +113,10 @@ public class BluetoothBarrierActivity extends AppCompatActivity implements View. BarrierStatus barrierStatus = BarrierStatus.extract(intent); String label = barrierStatus.getBarrierLabel(); int barrierPresentStatus = barrierStatus.getPresentStatus(); + if (label == null) { + mLogView.printLog("label is null."); + return; + } switch (label) { case KEEP_BARRIER_LABEL: if (barrierPresentStatus == BarrierStatus.TRUE) {