5 Hidden Android Studio Features That Will Boost Your Productivity

Pavel Parrado Marín
4 min readMar 9, 2023

--

Introduction

Android Studio is a powerful integrated development environment (IDE) that offers a wide range of features to help developers create high-quality Android apps. While some of these features are well-known, there are many hidden gems that can make a significant difference in a developer’s workflow. In this article, we’ll explore 10 of these hidden features that can boost your productivity and make coding in Android Studio a more enjoyable experience.

1. Surround with: Ctrl + Alt + T (W) / Cmd + Option + T (M)

If you want to surround a block of code with an if statement, for loop, or try-catch block, you can use the surround with feature. Simply select the code block and make a combination of these keys. It’s just amazing. You can wrap your composables with Box, Row or Column in 1 combination!

A quick example could be the as below.

Before:

fun openUrl(context: Context, url: String) {
val customTabsIntent = CustomTabsIntent.Builder().build()
customTabsIntent.launchUrl(context, Uri.parse(url))
}

After try catch:

fun openUrl(context: Context, url: String) {
try {
val customTabsIntent = CustomTabsIntent.Builder().build()
customTabsIntent.launchUrl(context, Uri.parse(url))
} catch (e: Exception) {
}
}

After if else:

fun openUrl(context: Context, url: String) {
if () {
val customTabsIntent = CustomTabsIntent.Builder().build()
customTabsIntent.launchUrl(context, Uri.parse(url))
} else {
}
}

2. Split editor

If you want to view two different parts of your code at the same time, you can split the editor. Simply right-click on the tab of the file you want to operate with. Real helper when you are in a large file, infinitely scrolling between methods and applying find operations instead of this gem function.

3. Extract Method: Ctrl + Alt + M (W) / Cmd + Option + M (M)

If you have a block of code that you want to reuse in multiple places, you can extract it into a separate method. Simply select the code block and press the combination mentioned above. A quick example below.

Before:

fun openLink(context: Context, url: String) {
val customTabsIntent = CustomTabsIntent.Builder().build()
customTabsIntent.launchUrl(context, Uri.parse(url))
}

After:

fun openLink(context: Context, url: String) {
createCustomTabsIntent(context, url)
}

private fun createCustomTabsIntent(context: Context, url: String) {
val customTabsIntent = CustomTabsIntent.Builder().build()
customTabsIntent.launchUrl(context, Uri.parse(url))
}

Basically, the goal is to extract a part of code to a method that is going to be reused in several places in a matter of seconds!

4. Bookmarks. Cmd + Options + line click (M) / Ctrl + Shift + F11(W)

A feature that allows you to quickly navigate to important parts of your code. Simply place the cursor on the line you want to bookmark and execute the command mentioned above.

Here is how it will look like:

And when you search for your Bookmars (Cmd + F3) you will see the following:

This feature will allow you to have in focus the most important parts of your code that you will need a quick navigation to. Simple time saver.

5. Live templates

They are pre-defined code snippets that you can quickly insert into your code by typing a short abbreviation. Android Studio has many built-in live templates, and you can create your own. You can access the live templates by starting to type or executing Ctrl + Alt + J(W) / CMD+J (M) to see all + built in suggested ones.

Here is a quick example of how it could look like.

You will have to create a new group and then add a template to it with the + button to the top right.

How we can quickly use the method from code.

  • By starting to type:

and upon selection it results into the code we provided in the template.

  • By pressing Ctrl + Alt + J(W) / CMD + J and selecting from the list of live templates we have:

By defining your own templates, you can speed up the creation of predefined operations, that you usually use in your architecture.

Conclusion

Android Studio is a powerful tool for developers to create innovative and complex applications for Android devices. However, many users may not be aware of some of its hidden features that can greatly enhance their productivity. By using features mentioned in this article, developers can streamline their workflow and reduce the time spent on routine tasks.

I hope you discovered something in this article!

--

--

Responses (6)