Posts

Showing posts from June, 2020

Using Robolectric to Test Classes with Dagger-Injected Dependencies in android

It is common for Android code to use dependency injection (DI). And one of the tenets of DI is to make code more testable. So it would follow that if your Android classes use DI, then they should be easily testable. That is true if your class uses constructor injection. You simply call the class’s constructor and provide implementations of its dependencies in the parameters to the constructor. Often, that means passing mocks of the dependencies so you can simulate various conditions in your unit test. But if your class uses field injection, then testing is a little tricker. In that case, you need to construct the object, and then somehow set the values of each injected field before you test any methods that use those fields. The real problem comes when your class uses field injection and you cannot control the creation lifecycle of the class. That is the case with several Android classes, like Activities and Views. The Android framework controls the creation of these. For examp

Android 3.0 Hardware Acceleration

One of the biggest changes we made to Android for Honeycomb is the addition of a new rendering pipeline so that applications can benefit from hardware accelerated 2D graphics.  Hardware accelerated graphics is nothing new to the Android platform, it has always been used for windows composition or OpenGL games for instance, but with this new rendering pipeline applications can benefit from an extra boost in performance.  On a Motorola Xoom device, all the standard applications like Browser and Calendar use hardware-accelerated 2D graphics. In this article, I will show you how to enable the hardware accelerated 2D graphics pipeline in your application and give you a few tips on how to use it properly. To learn complete android course visit  OnlineITguru's    android app development course . Go faster To enable the hardware accelerated 2D graphics, open your  AndroidManifest.xml  file and add the following attribute to the  <application />  tag: android : ha