How to use an AVAudioPlayer in iOS with Swift 5

If you write an app that should play sound here is a snippet for you import AVFoundation var player: AVAudioPlayer? let url = Bundle.main.path(forResource: “richtig”, ofType: “wav”) do { try AVAudioSession.sharedInstance().setMode(.default) try AVAudioSession.sharedInstance().setActive(true, options: .notifyOthersOnDeactivation) guard let url = url else { return } player = try AVAudioPlayer(contentsOf: URL(fileURLWithPath: url)) } catch { print(“Something went…

Play sound on Android

Motivation When writing app you sometimes want to play some sounds e.g. for notifications. In Android this can be accomplished by using the SoundPool class. Resource files Resource files e.g. your wav shall be placed under app\src\main\res\raw Code snippet This is a working example for playing short sound files. If you want to make a…

Android: Fix Unauthorized Devices on macOS

Disconnect USB connection between Mac/MacBook and Android device On the device: Revoke USB debugging authorization in Settings -> Developer Options cd /Users/<user_name>/Library/Android/sdk/platform-tools ./adb kill-server cd ~/.android/ rm -rf adbkey  Reconnect device Re-authorize computer to device cd /Users/<user_name>/Library/Android/sdk/platform-tools check with ./adb devices that device is authorized

Log4j2 PatternLayout Cheatsheet

In Log4j2 for Kotlin I’ve showed you how to configure a basic logger with log4j2. If you use a PatternLayout like this appender.console.layout.type = PatternLayout appender.console.layout.pattern = %m%n you can customize the appearance of the output. eg. appender.console.layout.pattern = %d{yyyy-mm-dd-HH:mm:ss.SSS} %-4p %C{1}.%M [%t] – %m%n%ex Parameter Parameter Meaning %m The log message %n line break…

Log4j2 for Kotlin

Motivation Logging is a common good practice in software engineering. It enables you to monitor applications in production to gather information about crashes and other malfunctions for further analysis. It is the “little brother” of debugging and often a precursor for setting up test cases which can lead to reproducing the bugs on the developers…