Compose & Paparazzi: Automatically find @Preview composables at runtime

Paparazzi is an Android library to render your application screens without a physical device or emulator. It can be used to test the current screens against a previous snapshot (golden). This can help ensure that the app's UI looks as expected. Paparazzi example The official Paparazzi website shows the following example: class LaunchViewTest { @get:Rule … Continue reading Compose & Paparazzi: Automatically find @Preview composables at runtime

Inject “runtime” arguments into viewmodel using dagger2’s assisted injection

Let's say you are implementing a movie app with the following screens: HomeActivity: Displays a list of movies. For each movie the poster and title are displayed.MovieActivity: Displays the details of a specific movie (overview, trailer, ratings, etc). When the user clicks on an item in HomeActivity, the app transitions to MovieActivity, where the details … Continue reading Inject “runtime” arguments into viewmodel using dagger2’s assisted injection

Smart dialogs with DialogFragment and ViewModel

In many situations you might need to show a dialog that has some behavior attached to it. For example, in my app Movie Pal, I show a Purchase Premium dialog that handles the entire purchase flow: Lists the features the user will get if they purchase premium Loads the price via a network call and … Continue reading Smart dialogs with DialogFragment and ViewModel

How to always use AdMob test Ads when developing

When using AdMob ads you are advised to use test ads when developing, otherwise you risk clicking on real ads by mistake, which could get your account banned. In this tutorial we will see how to configure your app to always use test ads when developing and real ads when running in release mode, with … Continue reading How to always use AdMob test Ads when developing

Potential traps to know about as an Android developer

I have been developing my own android apps for some time now. During this time, the most valuable lesson I have learned is that not all devices are the same. Things you might expect to work fail on some devices. You might be using a method that doesn't exist. Even though your code compiles just … Continue reading Potential traps to know about as an Android developer

How to convert a test from JUnit 4 to JUnit 5

Steps @Before → @BeforeEach @After → @AfterEach @BeforeClass → @BeforeAll @AfterClass → @AfterAll @org.junit.Test → @org.junit.jupiter.api.Test import static org.junit.Assert.assertTrue → import static org.junit.jupiter.api.Assertions.assertTrue (same for the other assertions) If using Mockito, @RunWith(MockitoJUnitRunner.class) → @ExtendWith(MockitoExtension.class) Example RED: Removed GREEN: Added import static org.junit.Assert.assertTrue; import static org.junit.jupiter.api.Assertions.assertTrue import org.junit.Before; import org.junit.jupiter.api.BeforeEach; import org.junit.Test; import org.junit.jupiter.api.Test; import org.junit.runner.RunWith; import … Continue reading How to convert a test from JUnit 4 to JUnit 5

How to exclude your own app’s activities from intent chooser

Let's say you have an app that can handle YouTube urls. You create an intent-filter so that the users will be asked with which app to handle them. Of course, within your app you add a Open in YouTube button so that the users can view information that your app may be missing. But you … Continue reading How to exclude your own app’s activities from intent chooser

“Programming Wars” – A code kata

Hello! My name is Minas, I'm a programmer and I enjoy creating stuff! My latest project is Movie Pal, an app you can use to discover movies, watch trailers, create shared watchlists with your friends and organize movie nights. Get it on Play Store. Code Katas are a fun way to challenge ourselves to learn … Continue reading “Programming Wars” – A code kata

Use Throwable.fillInStackTrace() when logging Volley exceptions

Volley is a famous library for Android that can used to execute HTTP requests (GET, POST, etc). As with most things, an HTTP request might fail. When this happens, Volley calls your error listener, supplying a VolleyError exception object. You can use this exception object to print the stack trace or, even better, report it … Continue reading Use Throwable.fillInStackTrace() when logging Volley exceptions