Get actual app ID and version from Android library without Context

References: How to get package name from anywhere? Get Android application package without Context Source code for android.app.ActivityThread This addresses the scenario where you are writing an Android library/SDK and it’s used in an app. How to get the actual app ID (package name) and version from inside the SDK? BuildConfig.APPLICATION_ID and BuildConfig.VERSION_NAME would return …

Simple Java logging class with inferred TAG

Been using a lot of Log.d(TAG, “message”); when working on Android projects. Problem with TAG is that it needs to be explicitly declared, e.g. protected String TAG = MyClass.class.getSimpleName(); instead of being inferred. Unlike PHP, Java has no magic constants such as __CLASS__ or __FUNCTION__ that can resolve automagically to the class/method being used at …

Resize view to fit aspect ratio of video in Android ExoPlayer

Been playing with ExoPlayer in Android and trying to resize a view to fit the aspect ratio of the video being played, i.e. fill the view with the video. References: Change resize mode for ExoPlayer Change aspect ratio of SurfaceView for ExoPlayer video 5-part series on building video player using ExoPlayer import android.view.ViewGroup.LayoutParams; import com.google.android.exoplayer2.Player.EventListener; …