Difference between await for and listen in Dart

Given: Stream<String> stream = new Stream<String>.fromIterable([‘mene’, ‘mene’, ‘tekel’, ‘parsin’]); then: print(‘BEFORE’); stream.listen((s) { print(s); }); print(‘AFTER’); yields: BEFORE AFTER mene mene tekel parsin whereas: print(‘BEFORE’); await for(String s in stream) { print(s); } print(‘AFTER’); yields: BEFORE mene mene tekel parsin AFTER stream.listen() sets up code that will be put on the event queue when an … 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

LoadError: Could not load the ‘listen’ gem (Rails 5)

If you are on rails 5 and you are using the default config/environments/development.rb file it will have this line of code in there. config.file_watcher = ActiveSupport::EventedFileUpdateChecker This requires the gem listen. This threw me for a bit as I was doing a rails 4 upgrades to a rails 5 edit: Forgot to mention that if … Read more