What is new in Android – Google IO 2016 – Quick Notes

1. Constraint Layout

Android Studio 2.2 Preview is included with the new layout system and design editor. By using drag-and-drop features, constraint layout automatically adds constraints to your views. The new editor also has design and blueprint view.

New constraint layout with design and blue print view
New constraint layout with design and blue print view

Continue reading What is new in Android – Google IO 2016 – Quick Notes

Ease Communication Between Activities, Fragments, and Services

Ease communication between Activities, Fragments, Dialogs, Services, AsyncTaks, and Life Cycles of Anything by using event bus in Android.

Event bus is an implementation of publish/subscribe pattern which is a messaging system between a subscriber and a publisher. A subscriber waits for an event to be dispatched from a publisher.

In this article I will describe how to benefit an event bus by using Greenrobot‘s EventBus library.

Table of contents
  1. What is subscribe and publish pattern
  2. EventBus in a nutshell
  3. How to add EventBus to your project
  4. How to use EventBus in 3 Steps
  5. Main features of EventBus
  6. Useful scenarios to use EventBus in your project
  7. Drawbacks of using EventBus in your project
  8. Alternatives to EventBus
  9. Conclusion(TL;DR)
  10. Example Project
example event bus project screenshot
Example EventBus Project

Continue reading Ease Communication Between Activities, Fragments, and Services

Bottom Sheets in Android

Bottom Sheets

A bottom sheet is a sheet that slides up from the bottom edge of the screen. Bottom sheets are displayed as a result of user triggered action, and also it can reveal additional content by swiping up.

A bottom sheet can be a structural part of your page and also it can be a temporary modal.

Bottom sheets are added to the Android Support Library in v23.2.0 version.

Continue reading Bottom Sheets in Android

String Resource Converter

Hello fellow developers,

I want to share with you my new tool which lets you to convert iOS String resources Localizable.strings to Android String resources strings.xml and vice-versa.

What it does;

It is a smart tool and it will make your job easier. If you are a cross platform developer then you can benefit from this tool. It will ease the process of converting string resources from one platform to another.

Strings Resource Converter is also located in the left menu.

Happy coding.

Android Studio 2.0 Preview is Released

We as android developers spend our time mostly on the IDE itself. Android Studio is the one of the most intelligent IDEs out there. Mainly because it is built on top of the most intelligent IDE, Intellij Idea.

Today at Android Dev Summit 2015, Android Studio 2.0 Preview edition is announced and available on the canary channel, therefore we can use the bleeding edge features of the newly released Android Studio 2.0 features right away without waiting to be released in stable channel.

New features in Android Studio 2.0

Continue reading Android Studio 2.0 Preview is Released

How to Change APK File Name in Android

Today, I want to share with you some valuable file naming scripts for gradle to change your artifact output file names.

Gradle is a build system which lets you to produce both android archives(.aar) and android packages(.apk) easily.

In android studio the gradle build settings will produce a very boring standart artifact name for you like output files by default.

Continue reading How to Change APK File Name in Android

Best Practice to Instantiate Fragments with Arguments in Android

There are some ways to instantiate and pass data to fragments in android development. However, you must be careful when you do that and you should avoid the wrong approaches while you are instantiating and passing data to fragments.

The most recommended way of instantiate fragments with arguments is to have factory methods for this task.

Also, another important topic is about how to pass data to the fragments while instantiating them. In this case it is tempting to directly access the fields of your fragment and assign their values. However, this is the wrong approach. Because when your application send back to background and the other applications require more and more memory then your application and its resources will be cleared from the memory to open up space to the new ones.

Continue reading Best Practice to Instantiate Fragments with Arguments in Android

Change Language Programmatically in Android

Update:

Published locale-helper as a library which can be found at https://github.com/zeugma-solutions/locale-helper-android

While developing your awesome application, sometimes you are required to add a feature to change the language of your app on the fly. However, Android OS does not directly support this behaviour. And therefore, you need to solve this situation in some other ways.

Android by default uses the locale of the device to select the appropriate language dependent resources. And most of the time this behaviour is enough for common applications.

However, sometimes there is some business requirements that you need to implement. To do that I will outline the details of changing the language of your application programmatically on the fly.

Here is the appropriate way of changing the locale of the application:

There are some difficulties which you have to overcome to change the language programmatically.

  1. Your application will not remember your language change after it is closed or recreated during the configuration change.
  2. You should update currently visible UI properly according to the selected language.

Continue reading Change Language Programmatically in Android

How to Solve Dex 65K Method Exception

While you gradually develop your application, you most probably would be encountered by the famous unable to execute dex exception.

 Conversion to Dalvik format failed:
Unable to execute dex: method ID not in [0, 0xffff]: 65536

or

 Conversion to Dalvik format failed:
Unable to execute dex: method ID not in [0, 0xffff]: 65536

You get this error mainly because there is a limitation on dalvik executable files and apparently the limit is 65536 which is 2^16 (two to the power sixteen).

This problem is also known as 65k method limit. So this limit is applied on the method count of your application. Android sdk methods are also counted. Therefore it is not that hard to reach out that limit. If you add a few third-party libraries to your gradle file and also android support libraries and google play services library, eventually you will hit the limit.

Continue reading How to Solve Dex 65K Method Exception

Anim Button – Inspired by Whatsapp

In some of the popular chat applications like whatsapp or hangouts, there is a button which can be transformed into a record button and also when you enter some text it will transform into a send button.

AnimButton is a custom ImageButton which is imitating the whatsapp’s send button behavior. Basically, it will change the image source when you enter some text on the edittext and it will go back when you clear the edittext

In this post I will try to mimic this behavior in my AnimButton project. Also, the full source code of the project can be found on the Github.

Continue reading Anim Button – Inspired by Whatsapp