Add badge count to navigation drawer hamburger icon – Android

Android
NavigationDrawer provides easy access to menu functions. Sometimes the menu items have some actionable content available. To notify user that some actionable content is available it is ok to provide some badge over the hamburger icon. ActionBarDrawerToggle provides a method setDrawerArrowDrawable() to provided custom drawer arrow drawable. Using this class we can provide a simple Badge which supports text to display any count. (more…)
Read More

Migrate to Android Room with Date column – Android

Android
Migrating our apps to Android Room from conventional SQLite Database was flawless except when we encountered issue with Date column type. Issue was that Android Room does not supported by the date column type. Let's suppose we have created table in SQLite database with following CREATE statement and we want to upgrade this table to Android Room. CREATE TABLE tblContact ( _id INTEGER, name TEXT, contact TEXT, created_on DATE, PRIMARY KEY(_id) ) To migrate this table to Android Room we need to follow four simple steps. Create Entity ClassCreate Type ConverterUpdate Entity class to use Long instead of Date Provide migration to incorporate the column data type changeUpdate database version and add migration Step1: Create Entity class While migrating the first step is to create an Entity class for the…
Read More

Generate app name with version code, name and flavour name – Android

Android
After a build is shared to a team or group of people, sometimes a question arises that what was the version code/name of the build shared, or from which product flavour it was from. Developers can inspect these details using analyse apk option in Android Studio. But, the problem is with other member who do not have Android studio to inspect these details. In order to resolve this issue, it is better to put these details with APK filename. In this way all the details can be verified just by looking at the filename. To achieve this we can put this gradle function in application level build.gradle file. android.applicationVariants.all { variant -> def appName // if applicationName property is set in gradle.properties if (project.hasProperty("applicationName")) { appName = applicationName } else…
Read More

Android: Is It Really Open-Source Software?

Android, apps
Today, more than ever, the opportunities for an app developer are seemingly limitless. At his fingertips, he has the ability to create apps (applications or software) for two major operating systems that run on mobile devices. And why not? The mobile platform is clearly where the most opportunity (and the most fiscal reward) lies. And if a developer knows how to write apps for Android and iOS, the potential is unlimited. Many see Android’s open-source approach as a clear benefit. But is Android truly open or does it just seem that way? Open-Source Defined To the average Android or iPhone user, phrases like “open-source” or “closed-source” are mystifying. All they see or understand is what happens on their devices. If the OS runs well, they can get the apps they…
Read More

Set up Continuous Integration server (Jenkins) for Android Projects

Android, Jenkins
Jenkins is one of the best open-source Continuous Integration server available. It helps in automating the builds and sharing of the application with minimal or no user interaction. In this post we are going to set up continuous integration server Jenkins for Android projects. Later this post will be extended for flavor specific build creation and sharing. Prerequisites: Ubuntu 16.04 server with root access Topics covered: In this article following two topics will be covered: Installation of Jenkins on Ubuntu 16.04Configure Jenkins accessConfigure for Android Projects 1. Installation of Jenkins on Ubuntu 16.04: In order to do this, login to the server with root access (in other words, access to terminal with #). Run following command to add the key of Jenkins to the machine. root@pcsalt:~# wget -q -O - http://pkg.jenkins-ci.org/debian/jenkins-ci.org.key…
Read More

Solution: Access to the dex task is now impossible, starting with 1.4.0

Android
Everybody* who wants to upgrade to and above 1.4.0 build tool version is getting this error. Error:Access to the dex task is now impossible, starting with 1.4.0 1.4.0 introduces a new Transform API allowing manipulation of the .class files. See more information: http://tools.android.com/tech-docs/new-build-system/transform-api As you can see by visiting the new build system: transform api that there is no solution provided. Follow the steps to solve the problem Access to the dex task is now impossible: (more…)
Read More

Product Flavors in Android

Android
Environment plays a vital role in the application development. As per the requirements, we have to create few environments, viz. Dev, QA, UAT, and Prod. In some projects, only a subset of these environments is required. So, with different environments comes different API endpoints. But for Android application development, most of the developers are still following the same old concept of enabling the endpoint of one environment and commenting endpoints of the rest of the environments. Now, we have Product Flavors in Android. And, it maintains the build as per the requirement. That is, there is no need to change in code if a build for a different environment is required. (more…)
Read More

Set margins in dp programmatically – Android

Android
Sometimes at runtime, it is required to set margin to a view. But, the problem is getting different size for different screen sizes, i.e. hdpi, xhdpi, xxhdpi, etc. This could be done easily with the help of screen specific value resources. Provide screen specific dimension values/dimen.xml <dimen name="margin_top_list_item">2dp</dimen> (more…)
Read More

EditText with Single Line, Line Wrapping and Done Action in Android

Android
Regular formula for making an EditText- Single Line : no new line <Enter> allowed,- Line Wrapping : Single line wrapped into multiple lines, and- Done Action : imeAction set as actionDone is possible through only XML properties. That is, android:inputType="text|textCapSentences" android:singleLine="true" android:lines="6" android:imeOptions="actionDone" But, only this is not enough. You need to set all these properties programatically. (more…)
Read More