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.

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

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

SparseArray vs HashMap

Main purpose of SparseArray in Android development is to have a memory efficient integer to object mapping.

It is not solely about to gain a performance tweak, however, you will save much more memory by using SparseArray.

Benefits of SparseArray

  • Saves you memory (Less memory usage thanks to the primitive keys and no Entry objects)
  • No auto-boxing (Because the keys are primitives e.g. int vs Integer, it will not convert your key to a new Integer(key))
  • Less time spend in GC-Garbage Collection- (With auto boxing there will be redundant Integer and Entry objects in the memory which needs to be collected by GC after their usage end)

Continue reading SparseArray vs HashMap