Example: Detecting Foreground and Background Events in Android: How Can You Effectively Identify Them? Code example for Medium Post.