Save time and improve productivity by using Live Templates for ConstraintLayout With more than 2.5 billion active android devices today, it has become a challenging task to create a fully responsive user interface (UI) for Android developers. Each device comes with different screen sizes, density, aspect ratio etc. But everyone wants to their apps to look exactly same on all devices. As Android ecosystem started growing year by year, Google started focusing more on solving problems of developers rather than adding new features.

Continue reading

Kotlin Extensions for simpler, easier and fun way of launching Activities in Android Reposted on my Medium profile. Few days ago, I was reading this awesome article by Elye about a Kotlin keyword reified . Soon after reading the article, I started exploring it and I realized that we can simply lots of reusable tasks of Android development using reified and Kotlin extension methods. For example, launching Activities.

Continue reading

In my current project at work, I had a task to add run time permissions in an android app whose code is very old and using legacy methods and frameworks/tools. Normally, I use Ted Permissions in all my apps for the runtime permissions and I must say that it’s one hell of an amazing library I ever saw and given the complex scenario and flow of runtime permissions in Android (thanks to Google who always makes sure to make every thing more complicated than ever), this library makes the runtime permissions like a breeze.

Continue reading

Today, when I was working on a project, so I had a situation where I had to perform a very tiny operation in background in Android. I had lots of ideas such as AsyncTask or Thread or using such powerful framework like RxJava or using new APIs such as JobDispatcher or WorkManager etc. You can read about these options in this good article by Ali Muzaffar. But my major concern was that my requirement was a very simple and little one.

Continue reading

Today, I had a huge Json in my app and I wanted to fetch all these values in a general way. I also wanted to parse Json for only one time to avoid try/catch each time I access any value. So, first thing I had in mind was to convert the JSONObject in the HashMap or Map<> etc. So if you are using Gson in your apps for json mapping, then you can use this one line code for conversion.

Continue reading

To showing/hiding the password dots in the EditText in android, here’s the easy one-line way. Here’s the dummy layout with an EditText and a CheckBox for toggling the password dots. <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_margin="16dp" android:orientation="vertical"> <EditText android:id="@+id/edtPassword" android:layout_width="match_parent" android:layout_height="wrap_content" android:hint="Enter password" android:inputType="textPassword" /> <android.support.v7.widget.AppCompatCheckBox android:id="@+id/checkbox" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Show Password" /> </LinearLayout> Now, you can toggle the password on the OnCheckedChangeListener using this snippet. checkbox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton compoundButton, boolean value) { if (value) { // Show Password edtPassword.

Continue reading

In my current project at work, I had to setup a private maven repository hosted at Artifactory. I was assigned login credentials to access the libraries (or artifacts) from the repository. But, when I was fetching it from Android Studio project through build.gradle file, I was getting this exception on syncing the project. org.gradle.internal.resource.transport.http.HttpRequestException: Could not GET 'MY_MAVEN_ARTIFACT_URL_GOES_HERE'. Caused by: java.net.SocketTimeoutException: Read timed out at java.net.SocketInputStream.socketRead0(Native Method) at java.net.SocketInputStream.socketRead(SocketInputStream.java:116) at java.

Continue reading

Author's picture

Wajahat Karim

Android Developer. Open Source Contributor. Writer. Speaker

Senior Android Developer

Karachi, Pakistan