System broadcast not delivered to the broadcast receiver
I'm trying to implement a receiver that reacts to Bluetooth devices being connected or disconnected. However, I only receive the broacasts when the application is open.
I've added the receiver to the manifest:
<receiver android:name=".BleReceiver"
android:enabled="true"
android:exported="true">
<intent-filter>
<action android:name="android.bluetooth.device.action.ACL_CONNECTED" />
<action android:name="android.bluetooth.device.action.ACL_DISCONNECTED" />
</intent-filter>
</receiver>
And my receiver looks like this:
public class BleReceiver extends BroadcastReceiver {
private static final String TAG = "BleReceiver";
@Override
public void onReceive(Context context, Intent intent) {
Log.d(TAG, "Got intent: " + intent.getAction());
}
}
This works just fine when the app is open, but if I eg. use the task switcher and swipe the activity, no broadcasts are received anymore.
The output of adb shell cmd package query-receivers --brief -a android.bluetooth.device.action.ACL_CONNECTED
looks just fine:
Receiver #3:
priority=0 preferredOrder=0 match=0x108000 specificIndex=-1 isDefault=false
com.example.blelistenerapp/.service.ble.BleReceiver
Also, I checked the implicit broadcast exceptions, and these two actions are listed there.
android broadcastreceiver
add a comment |
I'm trying to implement a receiver that reacts to Bluetooth devices being connected or disconnected. However, I only receive the broacasts when the application is open.
I've added the receiver to the manifest:
<receiver android:name=".BleReceiver"
android:enabled="true"
android:exported="true">
<intent-filter>
<action android:name="android.bluetooth.device.action.ACL_CONNECTED" />
<action android:name="android.bluetooth.device.action.ACL_DISCONNECTED" />
</intent-filter>
</receiver>
And my receiver looks like this:
public class BleReceiver extends BroadcastReceiver {
private static final String TAG = "BleReceiver";
@Override
public void onReceive(Context context, Intent intent) {
Log.d(TAG, "Got intent: " + intent.getAction());
}
}
This works just fine when the app is open, but if I eg. use the task switcher and swipe the activity, no broadcasts are received anymore.
The output of adb shell cmd package query-receivers --brief -a android.bluetooth.device.action.ACL_CONNECTED
looks just fine:
Receiver #3:
priority=0 preferredOrder=0 match=0x108000 specificIndex=-1 isDefault=false
com.example.blelistenerapp/.service.ble.BleReceiver
Also, I checked the implicit broadcast exceptions, and these two actions are listed there.
android broadcastreceiver
add a comment |
I'm trying to implement a receiver that reacts to Bluetooth devices being connected or disconnected. However, I only receive the broacasts when the application is open.
I've added the receiver to the manifest:
<receiver android:name=".BleReceiver"
android:enabled="true"
android:exported="true">
<intent-filter>
<action android:name="android.bluetooth.device.action.ACL_CONNECTED" />
<action android:name="android.bluetooth.device.action.ACL_DISCONNECTED" />
</intent-filter>
</receiver>
And my receiver looks like this:
public class BleReceiver extends BroadcastReceiver {
private static final String TAG = "BleReceiver";
@Override
public void onReceive(Context context, Intent intent) {
Log.d(TAG, "Got intent: " + intent.getAction());
}
}
This works just fine when the app is open, but if I eg. use the task switcher and swipe the activity, no broadcasts are received anymore.
The output of adb shell cmd package query-receivers --brief -a android.bluetooth.device.action.ACL_CONNECTED
looks just fine:
Receiver #3:
priority=0 preferredOrder=0 match=0x108000 specificIndex=-1 isDefault=false
com.example.blelistenerapp/.service.ble.BleReceiver
Also, I checked the implicit broadcast exceptions, and these two actions are listed there.
android broadcastreceiver
I'm trying to implement a receiver that reacts to Bluetooth devices being connected or disconnected. However, I only receive the broacasts when the application is open.
I've added the receiver to the manifest:
<receiver android:name=".BleReceiver"
android:enabled="true"
android:exported="true">
<intent-filter>
<action android:name="android.bluetooth.device.action.ACL_CONNECTED" />
<action android:name="android.bluetooth.device.action.ACL_DISCONNECTED" />
</intent-filter>
</receiver>
And my receiver looks like this:
public class BleReceiver extends BroadcastReceiver {
private static final String TAG = "BleReceiver";
@Override
public void onReceive(Context context, Intent intent) {
Log.d(TAG, "Got intent: " + intent.getAction());
}
}
This works just fine when the app is open, but if I eg. use the task switcher and swipe the activity, no broadcasts are received anymore.
The output of adb shell cmd package query-receivers --brief -a android.bluetooth.device.action.ACL_CONNECTED
looks just fine:
Receiver #3:
priority=0 preferredOrder=0 match=0x108000 specificIndex=-1 isDefault=false
com.example.blelistenerapp/.service.ble.BleReceiver
Also, I checked the implicit broadcast exceptions, and these two actions are listed there.
android broadcastreceiver
android broadcastreceiver
asked Nov 23 '18 at 12:32
manabreakmanabreak
2,52932155
2,52932155
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
Try
<receiver android:name=".BleReceiver">
<intent-filter>
<action android:name="android.bluetooth.device.action.ACL_CONNECTED" />
<action android:name="android.bluetooth.device.action.ACL_DISCONNECTED" />
<action android:name="android.bluetooth.adapter.action.STATE_CHANGED"/>
</intent-filter>
</receiver>
I'm not interested in listening if the Bluetooth was turned on or off. Anyway, I tried and that action is not delivered either when the app is not active.
– manabreak
Nov 23 '18 at 12:42
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53446793%2fsystem-broadcast-not-delivered-to-the-broadcast-receiver%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Try
<receiver android:name=".BleReceiver">
<intent-filter>
<action android:name="android.bluetooth.device.action.ACL_CONNECTED" />
<action android:name="android.bluetooth.device.action.ACL_DISCONNECTED" />
<action android:name="android.bluetooth.adapter.action.STATE_CHANGED"/>
</intent-filter>
</receiver>
I'm not interested in listening if the Bluetooth was turned on or off. Anyway, I tried and that action is not delivered either when the app is not active.
– manabreak
Nov 23 '18 at 12:42
add a comment |
Try
<receiver android:name=".BleReceiver">
<intent-filter>
<action android:name="android.bluetooth.device.action.ACL_CONNECTED" />
<action android:name="android.bluetooth.device.action.ACL_DISCONNECTED" />
<action android:name="android.bluetooth.adapter.action.STATE_CHANGED"/>
</intent-filter>
</receiver>
I'm not interested in listening if the Bluetooth was turned on or off. Anyway, I tried and that action is not delivered either when the app is not active.
– manabreak
Nov 23 '18 at 12:42
add a comment |
Try
<receiver android:name=".BleReceiver">
<intent-filter>
<action android:name="android.bluetooth.device.action.ACL_CONNECTED" />
<action android:name="android.bluetooth.device.action.ACL_DISCONNECTED" />
<action android:name="android.bluetooth.adapter.action.STATE_CHANGED"/>
</intent-filter>
</receiver>
Try
<receiver android:name=".BleReceiver">
<intent-filter>
<action android:name="android.bluetooth.device.action.ACL_CONNECTED" />
<action android:name="android.bluetooth.device.action.ACL_DISCONNECTED" />
<action android:name="android.bluetooth.adapter.action.STATE_CHANGED"/>
</intent-filter>
</receiver>
answered Nov 23 '18 at 12:35
Prasanth SPrasanth S
1,97472762
1,97472762
I'm not interested in listening if the Bluetooth was turned on or off. Anyway, I tried and that action is not delivered either when the app is not active.
– manabreak
Nov 23 '18 at 12:42
add a comment |
I'm not interested in listening if the Bluetooth was turned on or off. Anyway, I tried and that action is not delivered either when the app is not active.
– manabreak
Nov 23 '18 at 12:42
I'm not interested in listening if the Bluetooth was turned on or off. Anyway, I tried and that action is not delivered either when the app is not active.
– manabreak
Nov 23 '18 at 12:42
I'm not interested in listening if the Bluetooth was turned on or off. Anyway, I tried and that action is not delivered either when the app is not active.
– manabreak
Nov 23 '18 at 12:42
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53446793%2fsystem-broadcast-not-delivered-to-the-broadcast-receiver%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown