Tutorial: Set up Android UIAutomator in Eclipse

Remember my post about MonkeyTalk? UIAutomator seems to be even better automated andrroid app test suite - it does not require any dedicated libs in Android project and can work in any application (even if you do not have access to its source code. All this because it is nested in Android OS, so it … Continue reading Tutorial: Set up Android UIAutomator in Eclipse

Android status bar notifications [complete tutorial with source code]

Displaying status bar notification is a common way to unobtrusively inform user that something has happened (like new GMail message notification). In your app you can display it whenever you want. I will guide you how to do it from basics. This is how notifications are presented to the user: Google's documentation regarding the notifications … Continue reading Android status bar notifications [complete tutorial with source code]

Android: check device screen density programatically

When designing app for multiple screen sizes it is useful to check screen density (ldpi, mdpi, hdpi, xhdpi) and to know exact value in dpi. This is how to do it programatically: public void determineScreenDensity() { DisplayMetrics metrics = new DisplayMetrics(); getWindowManager().getDefaultDisplay().getMetrics(metrics); int density = metrics.densityDpi; if (density==DisplayMetrics.DENSITY_HIGH) { Toast.makeText(this, "DENSITY_HIGH: " + String.valueOf(density), Toast.LENGTH_LONG).show(); … Continue reading Android: check device screen density programatically

Android: check device screen size programatically

When designing app for multiple screen sizes it is useful to check screen size (small, normal, large, xlarge). This is how to do it programatically: public void determineScreenSize() { if((getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) == Configuration.SCREENLAYOUT_SIZE_LARGE) { Toast.makeText(this, "Large screen",Toast.LENGTH_LONG).show(); }else if ((getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) == Configuration.SCREENLAYOUT_SIZE_NORMAL) { Toast.makeText(this, "Normal sized screen" , Toast.LENGTH_LONG).show(); }else if ((getResources().getConfiguration().screenLayout … Continue reading Android: check device screen size programatically

Android: handle uncaught exceptions

To avoid the 'unfortunately app has stopped' dialog box, you can handle all uncaught exceptions in your app by setting custom handler. Uncaught exception Handler Paste this code in the beginning of your app. This will setup the handler. Do it only once, for example in onCreate of your fisrt activity that is displayed to … Continue reading Android: handle uncaught exceptions

Android rotate animation

Here is how to make view infinetely rotate around its center: 1. Define animation in xml Put this file in /res/anim: <?xml version="1.0" encoding="utf-8"?> <rotate xmlns:android="http://schemas.android.com/apk/res/android" android:duration="2500" android:interpolator="@android:anim/linear_interpolator" android:pivotX="50%" android:pivotY="50%" android:repeatCount="infinite" android:repeatMode="restart" android:toDegrees="360" > </rotate> 2. Load animation in java file I load it in onCreate and keep it as a class field. Thanks to … Continue reading Android rotate animation

How much do you know about programming?

Here is conference talk that takes audience in time travel few decades ago. Bret Victor is using old fashioned slide projector, has old fashioned clothes and pens in shirt pocket :) He is speaking about programming languages and computer evolution: Remarks Bret Victor prooves that computer evolution is tightly coupled with human's openess to change. … Continue reading How much do you know about programming?