Android Debug Vs Release Build Check in Running Code

Distinguishing Android Debug Mode Vs Release Mode

Your Android application (App) will execute in debug mode in you development environment (e.g. the Eclipse or Android Studio IDEs), and it will execute in release mode when installed from Google Play. In release mode any debug logging, StrictMode and the debugging option must be disabled. You can wrap the logging calls and StrictMode set up in code that checks for debug mode. To detect Android debug vs release mode there are two objects that expose a debug flag, ApplicationInfo (since API Level 1) and BuildConfig (recent SDK releases).

Android Debug vs Release Using ApplicationInfo Flags

With ApplicationInfo the flags field has a debug bit. It is set via the android:debuggable attribute on the application element in AndroidManifest.xml. Usually the android:debuggable attribute does not need to be present, it is set automatically by Eclipse or Android Studio. The IDEs set it to true to allow the App to be debugged. It is set to false to turn off debugging when the final APK is generated. To override the default settings add android:debuggable to the application element. Set it to true or false as required, e.g.:

To use it perform a boolean And on flags with ApplicationInfo.FLAG_DEBUGGABLE, if the result is not zero the App is in debug mode.

Android Debug vs Release Using BuildConfig.DEBUG

BuildConfig.DEBUG is set true when the App is running in the IDE. It is set false in the released APK unless android:debuggable is present and set true. Therefore  BuildConfig.DEBUG reflects the android:debuggable value unless android:debuggable is set false and the App is running in the IDE, in which case it will still be true. See the table later in the article. Continue reading

Call Forwarding Icon Keeps Appearing Android Galaxy Nexus

Removing the Call Forwarding Notification Icon on a Samsung Galaxy Nexus

Call Forwarding Icon Keeps Appearing AndroidAfter a recent trip abroad the Samsung Galaxy Nexus that was being used was turned off from Aeroplane mode. Up popped a notification to say that call forwarding was active, even though it had never been enabled. (The icon is a telephone handset with a arrow pointing outwards.)  Despite checking that the call forwarding option Always forward was indeed set to Disabled, and clearing notifications the icon (and notification) refused to go away. This particular phone is on the Three network in the UK. It was a simple solution in the end to fix the call forwarding icon keeps appearing android issue. It was to just dial ##20#. If you want the the full story read on.

Note, to access the call forwarding settings go to the dial keypad (via the handset icon) access the menu and select Settings then Call forwarding. The Forward when busyForward when unanswered and Forward when unreachable settings are configured for the 3 network’s voice mail number, 07782333123 (i.e. +447782333123). From the mobile phone voice mail is accessed by dialing 123. The phone appeared to be configured correctly but the call forwarding notification would not budge.

This Samsung Galaxy Nexus had failed to upgrade to Android 4.3 with the Over The Air (OTA) update prior to the trip. This needed to be done manually and would reset the phone. Which was planned for after the trip abroad. Following the Return to Stock for all Galaxy Nexus Phones guide on the xdadevelopers forum the Android 4.3 update was completed. (When doing manual system updates remember to back up everything as it will all be lost, music, data, texts, everything). The phone rebooted after the upgrade and pop, the call forwarding notification appeared. This meant it was a network or SIM card problem and not a phone issue.

What if the Call Forwarding Icon Keeps Appearing Android Samsung Galaxy Nexus?

Well a web search soon found the solution. It is a Three network issue. To clear the notification when the call forwarding icon keeps appearing Android Galaxy Nexus just dial ##20# and press the handset, as if making a call. A message should appear briefly to say erasure was successful or similar. Very simple solution in the end. If you get this issue let’s hope this solution works for you.

Android Icon Size – Launcher and Google Play Store

What is the Android Icon Size for an App?

For Android launcher icons you will need 6 sizes of PNG or JPG files. In pixels these are 48×48, 72×72, 96×96, 144×144, 192×192 and 512×512. The first five are for the App and the last one for when the App is deployed to the Google Play store. These are the final size of the icons and you must allow for a small margin, hence the area the icon is drawn in will be a bit smaller. For low density screens Android halves the 72×72 icon, but it is possible to include a 36×36 icon in the App for completeness, making 7 icons in total. An Android icon size table in this article summarizes all the relevant information.

144x144 XXHDPI Android Icon Size96x96 XHDPI Android Icon Size72x72 HDPI Android Icon Size48x48 MDPI Android Icon Size36x36 LDPI Android Icon Size

Android Screen Densities

The number of dots (pixels) per inch that an Android device’s screen holds determines how sharp the image on the screen looks. The more Dots Per Inch (DPI) the sharper the image. Android groups screen densities into several classes, medium, high, extra high, extra extra high and extra extra extra high! These are referred to as MDPI, HDPI, XHDPI, XXHDPI and XXXHDPI. There is also a low density class, LDPI, however not many new devices have a low density screen and thus LDPI is no longer important. MDPI is around 160 DPI, HDPI around 240 DPI, XHDPI around 320 DPI, XXHDPI around 480 DPI and XXXHDPI around 640 DPI. (LDPI is around 120 DPI). It is the screen density that determines the Android icon size used.

Android Launcher Icon Name and Location

When a new Android project is created in Eclipse or Android Studio the launcher icon file is called ic_launcher.png. You can choose the Create custom launcher icon option in the New Android Application wizard (New Project wizard in Android Studio). This allows you to configure the launcher icon based on the default Android robot, or an image file, or from several clip art images, or finally from some text. If an icon is not configured the default robot is used. The various size icons are created and placed into a folder in the projects res directory. The folders are drawable-mdpidrawable-hdpi, drawable-xhdpi and drawable-xxhdpi. It you need a low density, LDPI, icon create put a 36×36 PNG or JPG in the drawable-ldpi folder. To support Cupcake devices (API level 3) add a drawable folder and copy the 48×48 PNG or JPG file from drawable-mdpi to it. For the latest highest density displays create a drawable-xxxhdpi folder for a 192×192 icon.

The icon is referenced in the Android manifest. In the projects AndroidManifest.xml file the <application> tag has an android:icon attribute. This is set to @drawable/ic_launcher. The icon file’s name does not need to be ic_launcher, it can be called something else. For example if all the icon files for the various sizes were called my_app_icon.png then the attribute in the application tag could be set as android:icon=@drawable/my_app_icon.

Notice how the reference to the icon only needs the drawable part of the folder name. Android works out the correct density icon to use. Android will also scale one of the other density icons if an icon at a certain density is missing (though that may result in a fuzzy icon being displayed on the screen).

Android Icon Margins

The Android Operating System (OS) has evolved since it was released. This means that the icon requirements have changed over the years. The main changes are the increase in screen sizes and screen densities. Low density and medium density devices were common. Now high density and extra high density devices are the most common.

Previously it was recommend that the icon included a margin around one twelfth of the total size between the edge of the icon and the image it contained. For example the medium density icon is 48×48 pixels, one twelfth of this is 4, giving a margin of 4 pixels around the icon. This means the area available for the image is 40×40 (48 minus the margin of 4 pixels on each side).

However, the bigger screens on today’s devices gives more room for the icons so a smaller margin can be used, for example one eighteenth of the icon size. The margin allows for spaces between the icons on a screen and to allow for any drop shadows or parts of the image that stick out a little.

The High Resolution Application Icon needed for the Google Play store must be 512×512 in size. This image can have a margin to allow for padding or drop shadows, for example it could be 464×464 on the 512×512 canvas giving 48 pixels for padding and drop shadows. Again the size of the margin may depend upon the type of image being used, but the final file will be a 512×512 in size.

Android Bitmap Assets Ratios

With the 48×48 icon as baseline the 6 launcher icons have the ratios 0.75, 1, 1.5, 2, 3 and 4. These ratios apply to the screen densities. So a high density screen (HDPI) is 1.5 times a medium density screen (MDPI). I.e. 1.5 * 160 = 240. Likewise for the other densities. These ratios generally apply to all images used in an App that target different screen densities. If a bitmap is 100×100 on a medium density screen use the ratios to calculate the bitmap sizes required for other densities (75, 150, 200, 300 and 400 in this case). When generating icons and bitmap assets work at a high resolution and scale down, this prevents pixelation of the images. E.g. a canvas of 576×576 or 864×864 is good for design work. An art-board of those sizes is bigger than the biggest icon required (512×512 for the Google Play store). Even better use a vector drawing package such as Inkscape which effectively allows working at any resolution.

Android Icon Size Table

The following table summarizes all the above information.

Android Icon Size and Location for Apps
Density size Location Ratio Screen Margin
XXXHDPI 192×192 drawable-xxxhdpi 4 640 DPI 12 to 16 pixels
XXHDPI 144×144 drawable-xxhdpi 3 480 DPI 8 to 12 pixels
XHDPI 96×96 drawable-xhdpi 2 320 DPI 6 to 8 pixels
HDPI 72×72 drawable-hdpi 1.5 240 DPI 4 to 6 pixels
MDPI 48×48 drawable-mdpi 1 160 DPI 3 to 4 pixels
MDPI 48×48 drawable (Cupcake) 1 160 DPI 3 to 4 pixels
LDPI 36×36 drawable-ldpi 0.75 120 DPI 2 to 3 pixels
NA 512×512 Google Play NA NA As required

You will find a few icons on the Android Graphic Resources page, and of course many thousands more on the web.

For more information on Android Icons see the Iconography web page on the Android Developers web site.

SeekBar Android Example Code and Tutorial

Code To Demo A ProgessBar That Can Be Dragged

Understand how the SeekBar is used in an Android App. This tutorial provides some SeekBar Android example code for you to try out. This demo code for the SeekBar appears in the API Demos App that comes with the Android Software Development Kit (SDK). The API Demos App is very large and it can be difficult to find the sample code you need. Putting the SeekBar Android example here allows it to be easily referenced.

The SeekBar is a useful User Interface (UI) control. It allows a user to easily vary an integer value simply by dragging left or right. Although for very large integer values you may not have fine control and a EditText may be a better option. For small values, such as a percentage, it is a good solution for providing a value setting interface.

What Does an Android SeekBar Look Like?

The following two images compares the look of the SeekBar. The first shows it on older (original theme) devices, the second on recent Holo themed devices.

The Android SeekBar in action on older devices:

SeekBar Android Example Older Devices

The Android SeekBar in action on newer devices:

Seekbar Android Example Holo Devices

The SeekBar Android Example Code

Start by generating a new App in Eclipse, here it is called SeekBar Demo. (If you are new to Android programming see the articles Set Up Windows for Android Development and Your First Android Hello World Java Program.) You can of course add the SeekBar to an existing App by adapting the code appropriately. With the App open replace the contents of the MainActivity.javaactivity_main.xml and strings.xml files with the code shown below (keeping your chosen package name in the Java source code file). This code produces the screens shown above. Continue reading

App Monetization List of Marketplaces, Advertisers and Others

Marketplaces to Sell Apps, In-App Advertisers, Components and App Resellers

If you are interested in writing applications (Apps) for mobile devices then earning cash from them will also interest you. The term App monetization is used. What is monetization? It is about turning Apps (and other software, websites and projects) into a revenue stream. The lists in this article can help point the way. The main revenue stream is through running advertisements, but revenue can be earned via commission, sales or selling on what you have developed.

Trying to earn cash via App monetizationWhy Apps? For many consumers mobile devices, i.e. cell phones and tablet computers, have replaced the desktop as the main computing and browsing device. So much so that mobile devices are the most popular form of computing device. The most popular means the biggest market. It is also a market where consumers do not expect to pay large amounts for products and services. Hence the importance of concentrating App monetization around low cost and high volume. However, remember to keep quality high because user ratings ultimately drive the volume.

The following App monetization lists are far from complete, however, the lists will grow over time. The companies listed should be in alphabetically order, i.e. the position in the list has no meaning. The presence of an organisation in these lists is in no way an endorsement of their services. You must always perform your own checks on any products or services offered by a company. Cross border payments may prove difficult, for example US companies require the completion of a US tax form before payments are made. You may need to use a company that has a local presence to make payments easier.

List of App Stores

Also see the List of Android Appstores at the One Platform Foundation. The table provides useful links for developers.

List of In-App Advertisers for App Monetization

App and Code Resale Marketplaces

Looking to quit the App development business? For the right App Tek Eye has funds available for buyouts, contact us at dan@tekeye.biz for more details.

Adverts for Web Site Content

Information on Ad Sizes

See the Interactive Advertising Bureau (IAB)  advertisements size usages guidelines if you need help determining how big the adds in your content should be – http://www.iab.net/guidelines/508676/508767/displayguidelines

See our article on AdMob Ad Sizes.

Others

Contact us at dan@tekeye.biz if you would like your organisation considered for listing.