listen() ignores the backlog argument?

The backlog argument to listen() is only advisory. POSIX says: The backlog argument provides a hint to the implementation which the implementation shall use to limit the number of outstanding connections in the socket’s listen queue. Current versions of the Linux kernel round it up to the next highest power of two, with a minimum … Read more

Listen to volume buttons in background service?

It is possible. Use code below (for newer Android versions, especially Marshmallow, see bottom of the answer): public class SettingsContentObserver extends ContentObserver { int previousVolume; Context context; public SettingsContentObserver(Context c, Handler handler) { super(handler); context=c; AudioManager audio = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE); previousVolume = audio.getStreamVolume(AudioManager.STREAM_MUSIC); } @Override public boolean deliverSelfNotifications() { return super.deliverSelfNotifications(); } @Override public void … Read more