setBroadcast(true) hangs on Android
See original GitHub issueIn order to send broadcast messages we need to call setBroadcast()
first.
However this method hangs and never returns!
protected void doInBackgroundGuarded(Void... params) {
UdpSocketClient client = findClient(cId, callback);
if (client == null) {
return;
}
try {
client.setBroadcast(flag);
// **** we never get there!
callback.invoke();
} catch (SocketException e) {
callback.invoke(UdpErrorUtil.getError(null, e.getMessage()));
}
}
I tested in Android emulator and with a Samsung Galaxy S8. Both running on Android API 28. Any ideas what is going on here?
Issue Analytics
- State:
- Created 5 years ago
- Comments:6
Top Results From Across the Web
setBroadcast(true) not working on Android #96 - GitHub
When calling socket.setBroadcast(true) on Android after binding the socket, it makes whole the process hang forever. This method works on iOS.
Read more >Why BROADCAST receiver registration causing error. My app ...
You absolutely need to keep android:exported="true" , because this enables your broadcast receiver to listen to events triggered outside ...
Read more >Broadcasts overview | Android Developers
When a broadcast is sent, the system automatically routes broadcasts to apps ... other apps, even other apps that you own, set android:exported...
Read more >Android 8+ crash at boot_completed - MSDN - Microsoft
Below, you can see my broadcast receiver. [BroadcastReceiver( Name = "com.parroinfo.SERVICE_STARTUP", Enabled = true, Exported = true, ...
Read more >Get help during an emergency with your Android phone
Some of these steps work only on Android 12 and up. Learn how to check your Android version. ... Control emergency broadcast notifications....
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@nishmeht7: I did fix it 2 years ago (works very well in production code):
It seems we must not call
setBroadcast()
after the receiving thread was started, since this will result in a deadlock. Therefore I removed automatic start of receive on bind and introduced a new methodstartReveiving()
.See details in my commit above.
@shynst Thank you so much, you’re a life saver!