mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2025-01-12 18:57:36 +01:00
Flipper Zero: fixed crash due to unregistered boradcast receiver
This commit is contained in:
parent
570670fb28
commit
2554435284
@ -44,6 +44,7 @@ public class FlipperZeroSupport extends FlipperZeroBaseSupport{
|
||||
}).start();
|
||||
}
|
||||
};
|
||||
boolean recevierRegistered = false;
|
||||
|
||||
private void handlePlaySubGHZ(Intent intent) {
|
||||
String appName = intent.getExtras().getString("EXTRA_APP_NAME", "Sub-GHz");
|
||||
@ -88,7 +89,10 @@ public class FlipperZeroSupport extends FlipperZeroBaseSupport{
|
||||
|
||||
@Override
|
||||
protected TransactionBuilder initializeDevice(TransactionBuilder builder) {
|
||||
getContext().registerReceiver(receiver, new IntentFilter(COMMAND_PLAY_FILE));
|
||||
if(!recevierRegistered) {
|
||||
getContext().registerReceiver(receiver, new IntentFilter(COMMAND_PLAY_FILE));
|
||||
recevierRegistered = true;
|
||||
}
|
||||
|
||||
builder.add(new SetDeviceStateAction(getDevice(), GBDevice.State.INITIALIZING, getContext()));
|
||||
|
||||
@ -105,7 +109,10 @@ public class FlipperZeroSupport extends FlipperZeroBaseSupport{
|
||||
public void dispose() {
|
||||
super.dispose();
|
||||
|
||||
getContext().unregisterReceiver(receiver);
|
||||
if(recevierRegistered) {
|
||||
getContext().unregisterReceiver(receiver);
|
||||
recevierRegistered = false;
|
||||
}
|
||||
}
|
||||
|
||||
private void sendSerialData(byte[] data){
|
||||
|
Loading…
x
Reference in New Issue
Block a user