<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Developer Phil — An Android Developer's Blog</title>
    <description>An Android Developer's Blog</description>
    <link>http://www.developerphil.com/</link>
    <atom:link href="http://www.developerphil.com/feed.xml" rel="self" type="application/rss+xml"/>
    <pubDate>Mon, 19 Feb 2018 10:30:55 -0500</pubDate>
    <lastBuildDate>Mon, 19 Feb 2018 10:30:55 -0500</lastBuildDate>
    <generator>Jekyll v3.7.0</generator>
    
      <item>
        <title>Renaming Your Gradle Build Files</title>
        <description>&lt;p&gt;In a multi-module project, searching for the right &lt;code class=&quot;highlighter-rouge&quot;&gt;build.gradle&lt;/code&gt; can be tricky. After all, everything is called &lt;code class=&quot;highlighter-rouge&quot;&gt;build.gradle&lt;/code&gt; so using our trusty &lt;a href=&quot;/android-studio-tips-tricks-moving-around#open-file&quot; target=&quot;_blank&quot;&gt;Open File&lt;/a&gt; doesn’t help much. One neat trick to organize your code is to rename your &lt;code class=&quot;highlighter-rouge&quot;&gt;build.gradle&lt;/code&gt; file to something meaningful like &lt;code class=&quot;highlighter-rouge&quot;&gt;app.gradle&lt;/code&gt;, &lt;code class=&quot;highlighter-rouge&quot;&gt;my-feature.gradle&lt;/code&gt;, and so on.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/rename_gradle_files/open_renamed_gradle_file.png&quot; alt=&quot;Renamed Build.gradle files&quot; width=&quot;574&quot; /&gt;&lt;/p&gt;

&lt;h2 id=&quot;how-does-it-work&quot;&gt;How does it work&lt;/h2&gt;
&lt;p&gt;When you declare a module in your &lt;code class=&quot;highlighter-rouge&quot;&gt;settings.gradle&lt;/code&gt;,  the build system will look for a file named &lt;code class=&quot;highlighter-rouge&quot;&gt;build.gradle&lt;/code&gt; in a folder corresponding to the module’s name.  In other words, if you declare an &lt;code class=&quot;highlighter-rouge&quot;&gt;:app&lt;/code&gt; module, gradle will expect the build file to be located at &lt;code class=&quot;highlighter-rouge&quot;&gt;app/build.gradle&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Turns out that we can ignore this convention from our &lt;code class=&quot;highlighter-rouge&quot;&gt;settings.gradle&lt;/code&gt; with the  &lt;a href=&quot;https://docs.gradle.org/current/javadoc/org/gradle/api/initialization/ProjectDescriptor.html#setBuildFileName-java.lang.String-&quot; target=&quot;_blank&quot;&gt;&lt;code class=&quot;highlighter-rouge&quot;&gt;project.buildFileName&lt;/code&gt;&lt;/a&gt; property.&lt;/p&gt;

&lt;p&gt;Adding the following snippet to your &lt;code class=&quot;highlighter-rouge&quot;&gt;settings.gradle&lt;/code&gt; will rename each module’ s &lt;code class=&quot;highlighter-rouge&quot;&gt;build.gradle&lt;/code&gt; file to its module’s name. e.g. &lt;code class=&quot;highlighter-rouge&quot;&gt;app.gradle&lt;/code&gt;. The root &lt;code class=&quot;highlighter-rouge&quot;&gt;build.gradle&lt;/code&gt; itself won’t be renamed.&lt;/p&gt;
&lt;div class=&quot;language-groovy highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;c1&quot;&gt;// Add this at the end of settings.gradle&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;rootProject&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;children&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;each&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;subproject&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt; 
     &lt;span class=&quot;n&quot;&gt;subproject&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;buildFileName&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;${subproject.name}.gradle&quot;&lt;/span&gt; 
&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;If you are using &lt;a href=&quot;/nested-modules-in-gradle/&quot; target=&quot;_blank&quot;&gt;nested modules&lt;/a&gt;, you will need to add a bit of recursion to the mix to rename each submodule in the hierarchy. Replace the code above with the following:&lt;/p&gt;

&lt;div class=&quot;language-groovy highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;c1&quot;&gt;// Add this at the end of settings.gradle&lt;/span&gt;
&lt;span class=&quot;kt&quot;&gt;void&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;rename_build_file_to_module_name&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;project&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;n&quot;&gt;project&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;buildFileName&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;${project.name}.gradle&quot;&lt;/span&gt;
  &lt;span class=&quot;n&quot;&gt;project&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;children&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;each&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;child&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;rename_build_file_to_module_name&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;child&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;c1&quot;&gt;// Will rename every module's build.gradle file to use its name instead of `build`.&lt;/span&gt;
&lt;span class=&quot;c1&quot;&gt;// E.g. `app/build.gradle` will become `app/app.gradle`&lt;/span&gt;
&lt;span class=&quot;c1&quot;&gt;// The root build.gradle file will remain untouched&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;rootProject&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;children&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;each&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;subproject&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;rename_build_file_to_module_name&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;subproject&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;That’s all there is to it, we now have a new convention to look for files named after the module.&lt;/p&gt;

&lt;h3 id=&quot;renaming-the-files&quot;&gt;Renaming the files&lt;/h3&gt;
&lt;p&gt;Now that gradle knows where to find the files… you actually need to rename the files on disk!
You can go at it manually or run the following script at the root of your project.&lt;/p&gt;
&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;c&quot;&gt;#!/usr/bin/env bash&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;[[&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;!&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-f&lt;/span&gt; settings.gradle &lt;span class=&quot;o&quot;&gt;]]&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;then
    &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;'Make sure to run this at the root of your project'&lt;/span&gt;
    &lt;span class=&quot;nb&quot;&gt;exit &lt;/span&gt;1
&lt;span class=&quot;k&quot;&gt;fi

&lt;/span&gt;find &lt;span class=&quot;nb&quot;&gt;.&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-iname&lt;/span&gt; build.gradle &lt;span class=&quot;nt&quot;&gt;-not&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-path&lt;/span&gt; ./build.gradle  | &lt;span class=&quot;k&quot;&gt;while &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;read &lt;/span&gt;build_file&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;do
    &lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;moduledir&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;$(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;dirname&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$build_file&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;nv&quot;&gt;modulename&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;$(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;basename&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$moduledir&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;nv&quot;&gt;new_build_file&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$moduledir&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$modulename&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;.gradle&quot;&lt;/span&gt;
    &lt;span class=&quot;nb&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;Renaming'&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$build_file&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;' to &lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$new_build_file&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;
    &lt;span class=&quot;nb&quot;&gt;mv&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$build_file&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$new_build_file&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;done&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;The source code for this post is available &lt;a href=&quot;https://github.com/pbreault/rename_gradle_build_file_sample&quot; target=&quot;_blank&quot;&gt;here&lt;/a&gt;&lt;/p&gt;
</description>
        <pubDate>Mon, 19 Feb 2018 08:00:00 -0500</pubDate>
        <link>http://www.developerphil.com/renaming-your-gradle-build-files/</link>
        <guid isPermaLink="true">http://www.developerphil.com/renaming-your-gradle-build-files/</guid>
        
        
      </item>
    
      <item>
        <title>Nested Modules in Gradle</title>
        <description>&lt;p&gt;There are a many reasons to split your app in modules or projects&lt;sup id=&quot;fnref:modulevsproject&quot;&gt;&lt;a href=&quot;#fn:modulevsproject&quot; class=&quot;footnote&quot;&gt;1&lt;/a&gt;&lt;/sup&gt;. For a start, it’s mandatory to deploy an &lt;a href=&quot;https://developer.android.com/topic/instant-apps/getting-started/structure.html&quot; target=&quot;_blank&quot;&gt;Instant App&lt;/a&gt;. It’s also a good  way to speed up your incremental builds thanks to &lt;a href=&quot;https://blog.gradle.org/blazing-fast-android-builds&quot; target=&quot;_blank&quot;&gt;compilation avoidance&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;But, no matter what your reasons are, at some point, you will end up with a bunch of folders sorted alphabetically at the root of your project, and that will get confusing.&lt;/p&gt;

&lt;p&gt;Thankfully, Gradle allows us to organize our modules in folders.&lt;/p&gt;

&lt;p&gt;In this post, we will start from a flat structure:&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/nested_gradle_modules/gradle_flat_structure_diagram.svg&quot; alt=&quot;Flat Module Structure&quot; /&gt;&lt;/p&gt;

&lt;p&gt;And migrate it to a nested structure:
&lt;img src=&quot;/assets/nested_gradle_modules/gradle_nested_structure_diagram.svg&quot; alt=&quot;Nested Module Structure&quot; /&gt;&lt;/p&gt;

&lt;h2 id=&quot;step-1-move-the-modules-to-a-subfolder&quot;&gt;Step 1: Move the modules to a subfolder&lt;/h2&gt;

&lt;p&gt;&lt;img src=&quot;/assets/nested_gradle_modules/nested_structure_unsynced_ide.png&quot; alt=&quot;Flat Module Structure in Android Studio&quot; width=&quot;271&quot; /&gt;&lt;/p&gt;

&lt;p&gt;This is the most straightforward part: you are creating good old folders on your file system.
In this example, we will move our features to a folder named &lt;code class=&quot;highlighter-rouge&quot;&gt;feature&lt;/code&gt; and our helpers to a folder named &lt;code class=&quot;highlighter-rouge&quot;&gt;helpers&lt;/code&gt;.
Much like packages names, the trick here is to create a hierarchy that makes sense for your project.
Note that the project won’t compile just yet. That’s coming next.&lt;/p&gt;

&lt;h2 id=&quot;step-2-update-the-project-references&quot;&gt;Step 2: Update the project references&lt;/h2&gt;
&lt;p&gt;Gradle needs to be told the full path to a module. 
So you will need to update it  in your &lt;code class=&quot;highlighter-rouge&quot;&gt;settings.gradle&lt;/code&gt; file.&lt;/p&gt;

&lt;p&gt;Since we moved our features to the &lt;code class=&quot;highlighter-rouge&quot;&gt;feature/&lt;/code&gt; folder, the new path for &lt;code class=&quot;highlighter-rouge&quot;&gt;:my-first-feature&lt;/code&gt; would be &lt;code class=&quot;highlighter-rouge&quot;&gt;:feature:my-first-feature&lt;/code&gt;. Basically, it’s  the same file path where the path separator is a colon instead of  a forward/backward slash.&lt;/p&gt;

&lt;div class=&quot;language-groovy highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;c1&quot;&gt;// settings.gradle&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;include&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;':app'&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt;
    &lt;span class=&quot;s1&quot;&gt;':feature:my-first-feature'&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt;
    &lt;span class=&quot;s1&quot;&gt;':feature:my-second-feature'&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt;
    &lt;span class=&quot;s1&quot;&gt;':helpers:string-helpers'&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt;
    &lt;span class=&quot;s1&quot;&gt;':helpers:activity-helpers'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;You will also need to update your &lt;code class=&quot;highlighter-rouge&quot;&gt;build.gradle&lt;/code&gt; files wherever they are referencing a module that you just moved.&lt;/p&gt;

&lt;div class=&quot;language-groovy highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;c1&quot;&gt;// app/build.gradle&lt;/span&gt;
&lt;span class=&quot;c1&quot;&gt;// ...&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;dependencies&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;implementation&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;project&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;:feature:my-first-feature&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;implementation&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;project&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;:feature:my-second-feature&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;implementation&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;project&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;:helpers:activity-helpers&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;implementation&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;project&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;:helpers:string-helpers&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;c1&quot;&gt;// ...&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h2 id=&quot;the-final-result&quot;&gt;The final result&lt;/h2&gt;

&lt;p&gt;&lt;img src=&quot;/assets/nested_gradle_modules/nested_structure_ide.png&quot; alt=&quot;Nested Module Structure in Android Studio&quot; width=&quot;274&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Perform a &lt;code class=&quot;highlighter-rouge&quot;&gt;Gradle Sync&lt;/code&gt; from Android Studio and you will be ready to go.&lt;/p&gt;

&lt;p&gt;If you are executing a command on a nested module from the terminal, you will need to specify the module’s full path:&lt;/p&gt;
&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;./gradlew :feature:my-first-feature:check
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h3 id=&quot;caveats&quot;&gt;Caveats&lt;/h3&gt;
&lt;h4 id=&quot;the-android-view&quot;&gt;The Android View&lt;/h4&gt;
&lt;p&gt;&lt;img src=&quot;/assets/nested_gradle_modules/android_view.png&quot; alt=&quot;Android View&quot; width=&quot;199&quot; /&gt;&lt;/p&gt;

&lt;p&gt;The hierarchy is only visible from the &lt;code class=&quot;highlighter-rouge&quot;&gt;project&lt;/code&gt; view in Android Studio . 
The ‘Android’ view will flatten the hierarchy.&lt;/p&gt;

&lt;h4 id=&quot;iml-files&quot;&gt;IML files&lt;/h4&gt;
&lt;p&gt;The IDE might get confused the first time you move your folders.
If you see that Android Studio is not able to resync the project, delete all of the &lt;code class=&quot;highlighter-rouge&quot;&gt;*.iml&lt;/code&gt; files in the project and resync.&lt;/p&gt;

&lt;p&gt;The source code for this post is available &lt;a href=&quot;https://github.com/pbreault/nested-gradle-modules-sample&quot; target=&quot;_blank&quot;&gt;here&lt;/a&gt;&lt;/p&gt;

&lt;hr /&gt;

&lt;div class=&quot;footnotes&quot;&gt;
  &lt;ol&gt;
    &lt;li id=&quot;fn:modulevsproject&quot;&gt;
      &lt;p&gt;You will hear about &lt;em&gt;multi-module projects&lt;/em&gt; and &lt;em&gt;multi-project builds&lt;/em&gt;… They both represent the exact same thing but the naming varies between the IDE and the build system. What Android Studio and Intellij call a module, Gradle calls a project. So everything declared in your settings.gradle refers to a Gradle project. This is also the reason why we write &lt;code class=&quot;highlighter-rouge&quot;&gt;implementation project(':helper')&lt;/code&gt; when we want to import another module. &lt;a href=&quot;#fnref:modulevsproject&quot; class=&quot;reversefootnote&quot;&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
  &lt;/ol&gt;
&lt;/div&gt;
</description>
        <pubDate>Fri, 19 Jan 2018 08:00:00 -0500</pubDate>
        <link>http://www.developerphil.com/nested-modules-in-gradle/</link>
        <guid isPermaLink="true">http://www.developerphil.com/nested-modules-in-gradle/</guid>
        
        
      </item>
    
      <item>
        <title>No, You Can Not Override the Home Button... But You Don't Have To!</title>
        <description>&lt;h4 id=&quot;about-the-home-button&quot;&gt;About The Home Button&lt;/h4&gt;
&lt;p&gt;Every once in a while, somebody will ask “Can I override the Home button?”.
The response usually reads like this:&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;Of course you can’t! Handling the back button is already hard enough as it is, can you imagine what the world would look like if developers were allowed to mess with the home button!&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Behind this snarky answer lies a couple of truths:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;It would break the user’s expectations if the home button didn’t return home directly&lt;/li&gt;
  &lt;li&gt;Users could get trapped in an app&lt;/li&gt;
  &lt;li&gt;It would not cover every cases
    &lt;ul&gt;
      &lt;li&gt;What if the user leaves the app because of a phone call?&lt;/li&gt;
      &lt;li&gt;What if the user turns off the phone?&lt;/li&gt;
      &lt;li&gt;What if the user switched to another app by tapping on the  “recents” button?&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;So, in hindsight, unless you are writing a kiosk&lt;sup id=&quot;fnref:kiosk&quot;&gt;&lt;a href=&quot;#fn:kiosk&quot; class=&quot;footnote&quot;&gt;1&lt;/a&gt;&lt;/sup&gt; application, what you are probably looking for is a way to know when the user is leaving the Application. This would be so easy if the application had an &lt;code class=&quot;highlighter-rouge&quot;&gt;onStop()&lt;/code&gt; method, right?&lt;/p&gt;

&lt;h2 id=&quot;the-missing-application-onstart-and-onstop&quot;&gt;The Missing Application onStart() and onStop()&lt;/h2&gt;
&lt;p&gt;Actually, why stop at &lt;code class=&quot;highlighter-rouge&quot;&gt;onStop()&lt;/code&gt;? Let’s go one step further and try to map the whole foreground/background lifecycle so that we always know in what state we are and when that state changes.&lt;/p&gt;

&lt;p&gt;Why would you want that? Well, let’s say that your app has a messaging feature. If you receive a message and the app is in foreground, you might want to show a notification in your user interface. On the other hand, If the app is in background, showing a notification would be more appropriate.&lt;/p&gt;

&lt;p&gt;Other times, you might want to be notified of the whole foreground/background lifecycle to track session lengths. Or you might want to know if the user is moving on to something else so that you can clear your caches.&lt;/p&gt;

&lt;p&gt;Thankfully, you can get this information in a reliable way without resorting to crazy solutions like using &lt;a href=&quot;https://developer.android.com/reference/android/app/ActivityManager.html#getRunningTasks(int)&quot; target=&quot;_blank&quot;&gt;&lt;code class=&quot;highlighter-rouge&quot;&gt;ActivityManager#getRunningTask&lt;/code&gt;&lt;/a&gt; or instrumenting the activity lifecycle to detect when an &lt;code class=&quot;highlighter-rouge&quot;&gt;Activity#onStop()&lt;/code&gt; is not followed by an &lt;code class=&quot;highlighter-rouge&quot;&gt;Activity#onStart()&lt;/code&gt; fast enough.&lt;/p&gt;

&lt;h4 id=&quot;getting-notified-when-the-app-goes-in-background&quot;&gt;Getting Notified When The App Goes In Background&lt;/h4&gt;

&lt;p&gt;Starting with API Level 14 (Android 4.0 / ICS), we have access to the &lt;a href=&quot;https://developer.android.com/reference/android/app/Application.html#onTrimMemory(int)&quot; target=&quot;_blank&quot;&gt;&lt;code class=&quot;highlighter-rouge&quot;&gt;Application#onTrimMemory(int level)&lt;/code&gt;&lt;/a&gt; method. This method contains an interesting level called &lt;a href=&quot;https://developer.android.com/reference/android/content/ComponentCallbacks2.html#TRIM_MEMORY_UI_HIDDEN&quot; target=&quot;_blank&quot;&gt;&lt;code class=&quot;highlighter-rouge&quot;&gt;TRIM_MEMORY_UI_HIDDEN&lt;/code&gt;&lt;/a&gt; that can be used to know that we are going to the background.&lt;/p&gt;

&lt;p&gt;Here is an example of a custom &lt;a href=&quot;https://developer.android.com/reference/android/app/Application.html&quot; target=&quot;_blank&quot;&gt;&lt;code class=&quot;highlighter-rouge&quot;&gt;Application&lt;/code&gt;&lt;/a&gt; class:&lt;/p&gt;

&lt;div class=&quot;language-java highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;kd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;MyApplication&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;extends&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Application&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;c1&quot;&gt;// ...&lt;/span&gt;
    &lt;span class=&quot;nd&quot;&gt;@Override&lt;/span&gt;
    &lt;span class=&quot;kd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;void&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;onTrimMemory&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;level&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;kd&quot;&gt;super&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;onTrimMemory&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;level&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;);&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;level&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;TRIM_MEMORY_UI_HIDDEN&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
           &lt;span class=&quot;n&quot;&gt;isBackground&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;kc&quot;&gt;true&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;
           &lt;span class=&quot;n&quot;&gt;notifyBackground&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;();&lt;/span&gt;
        &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
    &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
    &lt;span class=&quot;c1&quot;&gt;// ...&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Yay!! Now you can know for sure that your app is being sent to the background!&lt;/p&gt;

&lt;h4 id=&quot;edit-getting-notified-when-the-screen-turns-off&quot;&gt;EDIT: Getting Notified When The Screen Turns Off&lt;/h4&gt;

&lt;p&gt;As noted by &lt;a href=&quot;http://www.developerphil.com/no-you-can-not-override-the-home-button-but-you-dont-have-to/#comment-2733674447&quot; target=&quot;_blank&quot;&gt;Guillaume Imbert&lt;/a&gt; in the comments, &lt;code class=&quot;highlighter-rouge&quot;&gt;onTrimMemory&lt;/code&gt; is not called when the screen gets turned off. To handle this, you will need to register a &lt;a href=&quot;https://developer.android.com/reference/android/content/BroadcastReceiver.html&quot; target=&quot;_blank&quot;&gt;&lt;code class=&quot;highlighter-rouge&quot;&gt;BroadcastReceiver&lt;/code&gt;&lt;/a&gt; on &lt;a href=&quot;https://developer.android.com/reference/android/content/Intent.html#ACTION_SCREEN_OFF&quot; target=&quot;_blank&quot;&gt;&lt;code class=&quot;highlighter-rouge&quot;&gt;Intent.ACTION_SCREEN_OFF&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;

&lt;div class=&quot;language-java highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;kd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;MyApplication&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;extends&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Application&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;c1&quot;&gt;// ...&lt;/span&gt;
  &lt;span class=&quot;nd&quot;&gt;@Override&lt;/span&gt;
    &lt;span class=&quot;kd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;void&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;onCreate&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;kd&quot;&gt;super&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;onCreate&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;();&lt;/span&gt;
        &lt;span class=&quot;c1&quot;&gt;// ...&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;IntentFilter&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;screenOffFilter&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;IntentFilter&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Intent&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;ACTION_SCREEN_OFF&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;);&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;registerReceiver&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;BroadcastReceiver&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
            &lt;span class=&quot;nd&quot;&gt;@Override&lt;/span&gt;
            &lt;span class=&quot;kd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;void&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;onReceive&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Context&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;context&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Intent&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;intent&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
              &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;isBackground&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
                  &lt;span class=&quot;n&quot;&gt;isBackground&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;kc&quot;&gt;false&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;
                  &lt;span class=&quot;n&quot;&gt;notifyForeground&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;();&lt;/span&gt;
              &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
            &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
        &lt;span class=&quot;o&quot;&gt;},&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;screenOffFilter&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;);&lt;/span&gt;
      &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;&lt;em&gt;Note that there is no need to listen for &lt;code class=&quot;highlighter-rouge&quot;&gt;Intent.ACTION_SCREEN_ON&lt;/code&gt;, it’s all handled down below&lt;/em&gt;&lt;/p&gt;

&lt;h4 id=&quot;getting-notified-when-the-app-returns-in-foreground&quot;&gt;Getting Notified When The App Returns In Foreground&lt;/h4&gt;

&lt;p&gt;There is no flag or trim level to know that we are re-entering the foreground. The best that we can do is wait for an &lt;code class=&quot;highlighter-rouge&quot;&gt;Activity#onResume()&lt;/code&gt;.
We could add all that code in a base Activity but that is not necessary. It would be cleaner to keep the foreground logic close to the background logic, so we will take advantage of &lt;a href=&quot;https://developer.android.com/reference/android/app/Application.html#registerActivityLifecycleCallbacks(android.app.Application.ActivityLifecycleCallbacks)&quot; target=&quot;_blank&quot;&gt;&lt;code class=&quot;highlighter-rouge&quot;&gt;Application#registerActivityLifecycleCallbacks()&lt;/code&gt;&lt;/a&gt;. This method allows you to add an &lt;a href=&quot;https://developer.android.com/reference/android/app/Application.ActivityLifecycleCallbacks.html&quot; target=&quot;_blank&quot;&gt;&lt;code class=&quot;highlighter-rouge&quot;&gt;ActivityLifecycleCallbacks&lt;/code&gt;&lt;/a&gt; which, as the name implies, calls you back for each and every lifecycle event. In our case, it means that we can have code that will run for every &lt;code class=&quot;highlighter-rouge&quot;&gt;Activity#onResume()&lt;/code&gt; without modifying any of our activities.&lt;/p&gt;

&lt;p&gt;Here is what it would look like in our custom &lt;a href=&quot;https://developer.android.com/reference/android/app/Application.html&quot; target=&quot;_blank&quot;&gt;&lt;code class=&quot;highlighter-rouge&quot;&gt;Application&lt;/code&gt;&lt;/a&gt; class:&lt;/p&gt;

&lt;div class=&quot;language-java highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;kd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;MyApplication&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;extends&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Application&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;c1&quot;&gt;// ...&lt;/span&gt;
    &lt;span class=&quot;nd&quot;&gt;@Override&lt;/span&gt;
       &lt;span class=&quot;kd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;void&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;onCreate&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
           &lt;span class=&quot;kd&quot;&gt;super&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;onCreate&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;();&lt;/span&gt;

           &lt;span class=&quot;n&quot;&gt;registerActivityLifecycleCallbacks&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Application&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;ActivityLifecycleCallbacks&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
               &lt;span class=&quot;c1&quot;&gt;// ...&lt;/span&gt;
               &lt;span class=&quot;nd&quot;&gt;@Override&lt;/span&gt;
               &lt;span class=&quot;kd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;void&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;onActivityResumed&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Activity&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;activity&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
                 &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;isBackground&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
                     &lt;span class=&quot;n&quot;&gt;isBackground&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;kc&quot;&gt;false&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;
                     &lt;span class=&quot;n&quot;&gt;notifyForeground&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;();&lt;/span&gt;
                 &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
               &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
               &lt;span class=&quot;c1&quot;&gt;// ...&lt;/span&gt;
           &lt;span class=&quot;o&quot;&gt;});&lt;/span&gt;
       &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
       &lt;span class=&quot;c1&quot;&gt;// ...&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h4 id=&quot;tying-it-all-together&quot;&gt;Tying It All Together&lt;/h4&gt;

&lt;p&gt;Alright, here is a more complete sample to be notified when the app enters foreground and is sent to background.&lt;/p&gt;

&lt;div class=&quot;language-java highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;kd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;MyApplication&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;extends&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Application&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;

    &lt;span class=&quot;c1&quot;&gt;// Starts as true in order to be notified on first launch&lt;/span&gt;
    &lt;span class=&quot;kd&quot;&gt;private&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;boolean&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;isBackground&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;kc&quot;&gt;true&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;

    &lt;span class=&quot;nd&quot;&gt;@Override&lt;/span&gt;
    &lt;span class=&quot;kd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;void&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;onCreate&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;kd&quot;&gt;super&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;onCreate&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;();&lt;/span&gt;

        &lt;span class=&quot;n&quot;&gt;listenForForeground&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;();&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;listenForScreenTurningOff&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;();&lt;/span&gt;
    &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;

    &lt;span class=&quot;kd&quot;&gt;private&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;void&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;listenForForeground&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;registerActivityLifecycleCallbacks&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;ActivityLifecycleCallbacks&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
            &lt;span class=&quot;c1&quot;&gt;//...&lt;/span&gt;
            &lt;span class=&quot;nd&quot;&gt;@Override&lt;/span&gt;
            &lt;span class=&quot;kd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;void&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;onActivityResumed&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Activity&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;activity&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
                &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;isBackground&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
                    &lt;span class=&quot;n&quot;&gt;isBackground&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;kc&quot;&gt;false&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;
                    &lt;span class=&quot;n&quot;&gt;notifyForeground&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;();&lt;/span&gt;
                &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
            &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
            &lt;span class=&quot;c1&quot;&gt;//...&lt;/span&gt;
        &lt;span class=&quot;o&quot;&gt;});&lt;/span&gt;
    &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;

    &lt;span class=&quot;kd&quot;&gt;private&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;void&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;listenForScreenTurningOff&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;IntentFilter&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;screenStateFilter&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;IntentFilter&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Intent&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;ACTION_SCREEN_OFF&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;);&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;registerReceiver&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;BroadcastReceiver&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
            &lt;span class=&quot;nd&quot;&gt;@Override&lt;/span&gt;
            &lt;span class=&quot;kd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;void&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;onReceive&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Context&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;context&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Intent&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;intent&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
                &lt;span class=&quot;n&quot;&gt;isBackground&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;kc&quot;&gt;true&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;
                &lt;span class=&quot;n&quot;&gt;notifyBackground&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;();&lt;/span&gt;
            &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
        &lt;span class=&quot;o&quot;&gt;},&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;screenStateFilter&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;);&lt;/span&gt;
    &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;

    &lt;span class=&quot;nd&quot;&gt;@Override&lt;/span&gt;
    &lt;span class=&quot;kd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;void&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;onTrimMemory&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;level&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;kd&quot;&gt;super&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;onTrimMemory&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;level&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;);&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;level&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;TRIM_MEMORY_UI_HIDDEN&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
            &lt;span class=&quot;n&quot;&gt;isBackground&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;kc&quot;&gt;true&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;
            &lt;span class=&quot;n&quot;&gt;notifyBackground&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;();&lt;/span&gt;
        &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;

    &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;

    &lt;span class=&quot;kd&quot;&gt;private&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;void&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;notifyForeground&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;c1&quot;&gt;// This is where you can notify listeners, handle session tracking, etc&lt;/span&gt;
    &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;

    &lt;span class=&quot;kd&quot;&gt;private&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;void&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;notifyBackground&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;c1&quot;&gt;// This is where you can notify listeners, handle session tracking, etc&lt;/span&gt;
    &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;

    &lt;span class=&quot;kd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;boolean&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;isBackground&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
      &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;isBackground&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h2 id=&quot;in-a-nutshell&quot;&gt;In a Nutshell&lt;/h2&gt;

&lt;ul&gt;
  &lt;li&gt;Target API 14&lt;/li&gt;
  &lt;li&gt;Use &lt;a href=&quot;https://developer.android.com/reference/android/app/Application.html#onTrimMemory(int)&quot; target=&quot;_blank&quot;&gt;&lt;code class=&quot;highlighter-rouge&quot;&gt;Application#onTrimMemory(int level)&lt;/code&gt;&lt;/a&gt; and &lt;a href=&quot;https://developer.android.com/reference/android/content/ComponentCallbacks2.html#TRIM_MEMORY_UI_HIDDEN&quot; target=&quot;_blank&quot;&gt;&lt;code class=&quot;highlighter-rouge&quot;&gt;TRIM_MEMORY_UI_HIDDEN&lt;/code&gt;&lt;/a&gt; to know when your are being sent to the background&lt;/li&gt;
  &lt;li&gt;Handle the screen turning off by registering a Broadcaster receiver for &lt;a href=&quot;https://developer.android.com/reference/android/content/Intent.html#ACTION_SCREEN_OFF&quot; target=&quot;_blank&quot;&gt;&lt;code class=&quot;highlighter-rouge&quot;&gt;Intent.ACTION_SCREEN_OFF&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;Register an &lt;a href=&quot;https://developer.android.com/reference/android/app/Application.ActivityLifecycleCallbacks.html&quot; target=&quot;_blank&quot;&gt;&lt;code class=&quot;highlighter-rouge&quot;&gt;ActivityLifecycleCallbacks&lt;/code&gt;&lt;/a&gt; to know when the app comes back to the foreground&lt;/li&gt;
  &lt;li&gt;Don’t try to override the home button&lt;/li&gt;
  &lt;li&gt;Be a nice person&lt;/li&gt;
&lt;/ul&gt;

&lt;hr /&gt;

&lt;p&gt;&lt;em&gt;Oh and big thanks to &lt;a href=&quot;https://twitter.com/benlikestocode&quot; target=&quot;_blank&quot;&gt;Ben Oberkfell&lt;/a&gt; for reviewing this post!&lt;/em&gt;&lt;/p&gt;

&lt;hr /&gt;

&lt;div class=&quot;footnotes&quot;&gt;
  &lt;ol&gt;
    &lt;li id=&quot;fn:kiosk&quot;&gt;
      &lt;p&gt;A kiosk application is basically having an app from which the user can’t escape. It is named that way because it usually means that a tablet will be embedded in a kiosk to display only one app. Think about “Point of Sales” scenario like ordering food in a restaurant, buying a train ticket, etc. If you are in this situation, the best way to go is to configure your app to be a single-use device. All the steps to achieve that are outlined in &lt;a href=&quot;https://codelabs.developers.google.com/codelabs/cosu/index.html?index=..%2F..%2Findex#0&quot; target=&quot;blank&quot;&gt;this codelab&lt;/a&gt; &lt;a href=&quot;#fnref:kiosk&quot; class=&quot;reversefootnote&quot;&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
  &lt;/ol&gt;
&lt;/div&gt;
</description>
        <pubDate>Wed, 15 Jun 2016 21:50:00 -0400</pubDate>
        <link>http://www.developerphil.com/no-you-can-not-override-the-home-button-but-you-dont-have-to/</link>
        <guid isPermaLink="true">http://www.developerphil.com/no-you-can-not-override-the-home-button-but-you-dont-have-to/</guid>
        
        
      </item>
    
      <item>
        <title>Android Studio Tips Of the Day - Roundup #6</title>
        <description>&lt;p&gt;This is the sixth roundup of my Android Studio Daily Tips that I post on &lt;a href=&quot;https://plus.google.com/+PhilippeBreault/&quot;&gt;Google+&lt;/a&gt;&lt;br /&gt;
You can take a look at the previous post &lt;a href=&quot;/android-studio-tips-of-the-day-roundup-5/&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;h4 id=&quot;about-keymaps&quot;&gt;About Keymaps&lt;/h4&gt;

&lt;p&gt;Android Studio provides different keymaps (the mapping between shortcut keys and an action).
You can see which keymap you are using in &lt;em&gt;Settings-&amp;gt;Keymap&lt;/em&gt;.&lt;/p&gt;

&lt;p style=&quot;margin-bottom:0.25em&quot;&gt;It wouldn’t be practical to list the shortcuts for every keymap so the following will be used:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Windows: Default&lt;/li&gt;
  &lt;li&gt;Linux: Default&lt;/li&gt;
  &lt;li&gt;OSX: Mac OSX 10.5+&lt;/li&gt;
&lt;/ul&gt;

&lt;hr /&gt;

&lt;h3 id=&quot;refactor-this&quot;&gt;Refactor This&lt;/h3&gt;
&lt;p&gt;&lt;img src=&quot;/assets/48-refactorthis.png&quot; alt=&quot;Refactor This&quot; /&gt;&lt;/p&gt;

&lt;p&gt;This is a shortcut to contextually show all the available refactorings for the current selection.
This list is keyboard searchable and you can use the number on the left for a quicker access&lt;/p&gt;

&lt;p style=&quot;margin-bottom:0.25em&quot;&gt;Shortcut (Menu):&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Mac: Ctrl+T&lt;/li&gt;
  &lt;li&gt;Windows/Linux: Ctrl+Alt+Shift+T&lt;/li&gt;
&lt;/ul&gt;

&lt;hr /&gt;

&lt;h3 id=&quot;navigate-to-parent&quot;&gt;Navigate to parent&lt;/h3&gt;
&lt;p&gt;&lt;img src=&quot;/assets/39-navigatetoparent.gif&quot; alt=&quot;Navigate to parent&quot; /&gt;&lt;/p&gt;

&lt;p&gt;If you are in a method that is overriding a parent class (e.g. Activity#onCreate()), this will navigate to the parent implementation.&lt;/p&gt;

&lt;p&gt;If you are on the class name, it will navigate to the parent class.&lt;/p&gt;

&lt;p style=&quot;margin-bottom:0.25em&quot;&gt;Shortcut :&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Mac: Cmd+U&lt;/li&gt;
  &lt;li&gt;Windows/Linux: Ctrl+U&lt;/li&gt;
&lt;/ul&gt;

&lt;hr /&gt;

&lt;h3 id=&quot;recently-changed-files&quot;&gt;Recently Changed Files&lt;/h3&gt;
&lt;p&gt;&lt;img src=&quot;/assets/49-recentlyedited.gif&quot; alt=&quot;Recently Changed Files&quot; /&gt;&lt;/p&gt;

&lt;p&gt;This is a variation of the “Recents” popup that lists files that were recently modified locally.
It is sorted in order of modification (most recently edited on top).
A nice bonus is that you can type to filter the list.&lt;/p&gt;

&lt;p style=&quot;margin-bottom:0.25em&quot;&gt;Shortcut (Menu):&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Mac: Cmd+Shift+E&lt;/li&gt;
  &lt;li&gt;Windows/Linux: Ctrl+Shift+E&lt;/li&gt;
&lt;/ul&gt;

&lt;hr /&gt;

&lt;h3 id=&quot;jump-to-last-tool-window&quot;&gt;Jump to Last Tool Window&lt;/h3&gt;

&lt;p&gt;&lt;img src=&quot;/assets/41-lasttoolwindow.gif&quot; alt=&quot;Jump to Last Tool Window&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Sometimes, you return to the editor from a panel but find yourself having to go back to this panel.
e.g. browsing &lt;em&gt;find usages&lt;/em&gt;.
With this, you can go back to a panel without your mouse.&lt;/p&gt;

&lt;p&gt;Shortcut: F12  (might interfere with the OS’s default keybindings)&lt;/p&gt;

&lt;hr /&gt;

&lt;h2 id=&quot;related-file&quot;&gt;Related File&lt;/h2&gt;
&lt;p&gt;&lt;img src=&quot;/assets/50-relatedfile.gif&quot; alt=&quot;Related File&quot; /&gt;&lt;/p&gt;

&lt;p&gt;It helps you navigate between your layout and your activity/fragment with ease.
There is also a shortcut in the gutter next to the class name and one at the top of the layout file.&lt;/p&gt;

&lt;p style=&quot;margin-bottom:0.25em&quot;&gt;Shortcut (Menu):&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Mac: Ctrl+Cmd+Up&lt;/li&gt;
  &lt;li&gt;Windows/Linux: Ctrl+Alt+Home&lt;/li&gt;
&lt;/ul&gt;

&lt;hr /&gt;

&lt;h3 id=&quot;extract-variable&quot;&gt;Extract Variable&lt;/h3&gt;
&lt;p&gt;&lt;img src=&quot;/assets/51-extractvariable.gif&quot; alt=&quot;Extract Variable&quot; /&gt;&lt;/p&gt;

&lt;p&gt;This is a shortcut to extract a variable without going through the refactoring menu.&lt;/p&gt;

&lt;p&gt;This is very useful when you are generating code on the fly as you can avoid typing the variable declaration and go straight to the value. The IDE will then generate the declaration and it will come up with some suggestions on how to name the variable.&lt;/p&gt;

&lt;p style=&quot;margin-bottom:0.25em&quot;&gt;Additional tip:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;If you want to change the declaration type to something more generic (e.g. List instead of ArrayList), you can press &lt;em&gt;Shift+Tab&lt;/em&gt; and it will give you a list of valid types.&lt;/li&gt;
&lt;/ul&gt;

&lt;p style=&quot;margin-bottom:0.25em&quot;&gt;Shortcut (Menu):&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Mac: Cmd+Alt+V&lt;/li&gt;
  &lt;li&gt;Windows/Linux: Ctrl+Alt+V&lt;/li&gt;
&lt;/ul&gt;

&lt;hr /&gt;

&lt;h3 id=&quot;extract-parameter&quot;&gt;Extract Parameter&lt;/h3&gt;
&lt;p&gt;&lt;img src=&quot;/assets/52-extractparam.gif&quot; alt=&quot;Extract Parameter&quot; /&gt;&lt;/p&gt;

&lt;p&gt;This is a shortcut to extract a parameter without going through the refactoring menu.&lt;/p&gt;

&lt;p&gt;This thing is useful when you realize that a method could be generified by extracting one part as a parameter. The way it works is that it will take the current value, make it a parameter and copy the old value as the parameter for each caller.&lt;/p&gt;

&lt;p style=&quot;margin-bottom:0.25em&quot;&gt;Additional tip:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;You can also keep the original method and have it delegate to the new one by ticking the “delegate” box.&lt;/li&gt;
&lt;/ul&gt;

&lt;p style=&quot;margin-bottom:0.25em&quot;&gt;Shortcut (Menu):&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Mac: Cmd+Alt+P&lt;/li&gt;
  &lt;li&gt;Windows/Linux: Ctrl+Alt+P&lt;/li&gt;
&lt;/ul&gt;

&lt;hr /&gt;

&lt;h3 id=&quot;extract-method&quot;&gt;Extract Method&lt;/h3&gt;
&lt;p&gt;&lt;img src=&quot;/assets/53-extractmethod.gif&quot; alt=&quot;Extract Method&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Following in my streak of extract refactoring, here is the one to extract a code block in a new method.&lt;/p&gt;

&lt;p&gt;This thing is extremely useful. Whenever you encounter a method that is starting to become a bit complex, you can use this to safely extract a portion in another method. I say safely because the IDE won’t make a silly copy-paste mistake like we might do.&lt;/p&gt;

&lt;p style=&quot;margin-bottom:0.25em&quot;&gt;Additional tip:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Once you are in the extractin dialog, you can change the visibility of the method and the parameter names.&lt;/li&gt;
&lt;/ul&gt;

&lt;p style=&quot;margin-bottom:0.25em&quot;&gt;Shortcut (Menu):&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Mac: Cmd+Alt+M&lt;/li&gt;
  &lt;li&gt;Windows/Linux: Ctrl+Alt+M&lt;/li&gt;
&lt;/ul&gt;

&lt;hr /&gt;

&lt;h3 id=&quot;inline&quot;&gt;Inline&lt;/h3&gt;
&lt;p&gt;&lt;img src=&quot;/assets/54-inline.gif&quot; alt=&quot;Inline&quot; /&gt;&lt;/p&gt;

&lt;p&gt;So you have gone a bit crazy with extraction and now you have too much stuff? You can do the reverse operation, which is called “inline”.&lt;/p&gt;

&lt;p&gt;This will work with methods, fields, parameters and variables.&lt;/p&gt;

&lt;p style=&quot;margin-bottom:0.25em&quot;&gt;Shortcut:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Mac: Cmd+Alt+N&lt;/li&gt;
  &lt;li&gt;Windows/Linux: Ctrl+Alt+M&lt;/li&gt;
&lt;/ul&gt;

&lt;hr /&gt;

&lt;h3 id=&quot;rename&quot;&gt;Rename&lt;/h3&gt;
&lt;p&gt;&lt;img src=&quot;/assets/55-rename.gif&quot; alt=&quot;Rename&quot; /&gt;&lt;/p&gt;

&lt;p&gt;With this, you can rename a variable, field, method, class and event package.
This will, of course, make sure that the renaming makes sense in the context of your app, it won’t simply do a find and replace in all files!&lt;/p&gt;

&lt;p style=&quot;margin-bottom:0.25em&quot;&gt;Additional Tip:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;If you can’t remember this shortcut, you can always invoke the quick fix shortcut and it will always include the rename refactoring.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Shortcut: Shift+F6&lt;/p&gt;

&lt;hr /&gt;

&lt;h3 id=&quot;pull-up--push-down&quot;&gt;Pull Up / Push Down&lt;/h3&gt;
&lt;p&gt;&lt;img src=&quot;/assets/56-pullupdown.gif&quot; alt=&quot;Pull Up / Push Down&quot; /&gt;&lt;/p&gt;

&lt;p&gt;When we talk about pulling something up, we mean that we will take something in the current class (usually a method or a field) and send it to the parent class or interface.&lt;/p&gt;

&lt;p&gt;If the parent is a class, the content will be moved.
If the parent is an interface, it will declare the method as part of the interface, keep the method in your class and add the @override annotation.&lt;/p&gt;

&lt;p&gt;When we talk about pushing members down, that is exactly the opposite operation, we are sending content from the parent class/interface in the child class.&lt;/p&gt;

&lt;p style=&quot;margin-bottom:0.25em&quot;&gt;Shortcut:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Mac: Ctrl+T and choose pull members up / push members down&lt;/li&gt;
  &lt;li&gt;Windows/Linux: Ctrl+Alt+Shift+T and choose pull members up / push members down&lt;/li&gt;
&lt;/ul&gt;
</description>
        <pubDate>Tue, 24 Feb 2015 18:10:00 -0500</pubDate>
        <link>http://www.developerphil.com/android-studio-tips-of-the-day-roundup-6/</link>
        <guid isPermaLink="true">http://www.developerphil.com/android-studio-tips-of-the-day-roundup-6/</guid>
        
        
      </item>
    
      <item>
        <title>Android Studio Tips Of the Day - Roundup #5</title>
        <description>&lt;p&gt;This is the fifth roundup of my Android Studio Daily Tips that I post on &lt;a href=&quot;https://plus.google.com/+PhilippeBreault/&quot;&gt;Google+&lt;/a&gt;&lt;br /&gt;
You can take a look at the previous post &lt;a href=&quot;/android-studio-tips-of-the-day-roundup-4/&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;h4 id=&quot;about-keymaps&quot;&gt;About Keymaps&lt;/h4&gt;

&lt;p&gt;Android Studio provides different keymaps (the mapping between shortcut keys and an action).
You can see which keymap you are using in &lt;em&gt;Settings-&amp;gt;Keymap&lt;/em&gt;.&lt;/p&gt;

&lt;p style=&quot;margin-bottom:0.25em&quot;&gt;It wouldn’t be practical to list the shortcuts for every keymap so the following will be used:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Windows: Default&lt;/li&gt;
  &lt;li&gt;Linux: Default&lt;/li&gt;
  &lt;li&gt;OSX: Mac OSX 10.5+&lt;/li&gt;
&lt;/ul&gt;

&lt;hr /&gt;

&lt;h3 id=&quot;enter-vs-tab-for-code-completion&quot;&gt;Enter vs Tab for Code Completion&lt;/h3&gt;
&lt;p&gt;&lt;img src=&quot;/assets/45-codecompletionentertab.gif&quot; alt=&quot;Enter vs Tab for Code Completion&quot; /&gt;&lt;/p&gt;

&lt;p&gt;There is an interesting difference whether you use code completion with tab or with enter.&lt;/p&gt;

&lt;p&gt;Using enter will complete the statement as you would expect.
Using tab will complete the statement and delete everything forward until the next dot, parenthese, semicolon or space.&lt;/p&gt;

&lt;p&gt;Shortcut (during code completion): enter or tab&lt;/p&gt;

&lt;hr /&gt;

&lt;h3 id=&quot;navigate-to-parent&quot;&gt;Navigate to parent&lt;/h3&gt;
&lt;p&gt;&lt;img src=&quot;/assets/39-navigatetoparent.gif&quot; alt=&quot;Navigate to parent&quot; /&gt;&lt;/p&gt;

&lt;p&gt;If you are in a method that is overriding a parent class (e.g. Activity#onCreate()), this will navigate to the parent implementation.&lt;/p&gt;

&lt;p&gt;If you are on the class name, it will navigate to the parent class.&lt;/p&gt;

&lt;p style=&quot;margin-bottom:0.25em&quot;&gt;Shortcut :&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Mac: Cmd+U&lt;/li&gt;
  &lt;li&gt;Windows/Linux: Ctrl+U&lt;/li&gt;
&lt;/ul&gt;

&lt;hr /&gt;

&lt;h3 id=&quot;return-to-the-editor&quot;&gt;Return to the Editor&lt;/h3&gt;
&lt;p&gt;&lt;img src=&quot;/assets/40-returntoeditor.gif&quot; alt=&quot;Return to the Editor&quot; /&gt;&lt;/p&gt;

&lt;p&gt;A bunch of shortcuts will take you away from the editor (type hierarchy, find usages, etc.)&lt;/p&gt;

&lt;p style=&quot;margin-bottom:0.25em&quot;&gt;If you want to return to the editor, your options are:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Escape: This will simply return the cursor to the editor.&lt;/li&gt;
  &lt;li&gt;Shift+Escape: This will close the current panel and then return your cursor to the editor.&lt;/li&gt;
&lt;/ul&gt;

&lt;p style=&quot;margin-bottom:0.25em&quot;&gt;Shortcut :&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Return and keep panel open: Escape&lt;/li&gt;
  &lt;li&gt;Close panel and Return: Shift+Escape&lt;/li&gt;
&lt;/ul&gt;

&lt;hr /&gt;

&lt;h3 id=&quot;jump-to-last-tool-window&quot;&gt;Jump to Last Tool Window&lt;/h3&gt;

&lt;p&gt;&lt;img src=&quot;/assets/41-lasttoolwindow.gif&quot; alt=&quot;Jump to Last Tool Window&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Sometimes, you return to the editor from a panel but find yourself having to go back to this panel.
e.g. browsing &lt;em&gt;find usages&lt;/em&gt;.
With this, you can go back to a panel without your mouse.&lt;/p&gt;

&lt;p&gt;Shortcut: F12  (might interfere with the OS’s default keybindings)&lt;/p&gt;

&lt;hr /&gt;

&lt;h2 id=&quot;hide-all-panels&quot;&gt;Hide All Panels&lt;/h2&gt;
&lt;p&gt;&lt;img src=&quot;/assets/42-hideallwindows.gif&quot; alt=&quot;Hide All Panels&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Puts the editor in some sort of full screen mode.
Invoking the shortcut a second time returns all panels to their previous state.&lt;/p&gt;

&lt;p style=&quot;margin-bottom:0.25em&quot;&gt;Shortcut :&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Mac: Cmd+Shift+F12&lt;/li&gt;
  &lt;li&gt;windows/linux: Ctrl+Shift+F12&lt;/li&gt;
&lt;/ul&gt;

&lt;hr /&gt;

&lt;h3 id=&quot;open-a-panel-by-its-number&quot;&gt;Open a Panel by Its Number&lt;/h3&gt;
&lt;p&gt;&lt;img src=&quot;/assets/43-openpanelbynumber.gif&quot; alt=&quot;Open a Panel by Its Number&quot; /&gt;&lt;/p&gt;

&lt;p&gt;You might have noticed that some of the panels have a number to the left of their name.
This is a shortcut to open them!&lt;/p&gt;

&lt;p&gt;Just in case you don’t see the panel names, click the box thing in the lower left corner of the IDE.&lt;/p&gt;

&lt;p style=&quot;margin-bottom:0.25em&quot;&gt;Shortcut :&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Mac: Cmd+Number&lt;/li&gt;
  &lt;li&gt;windows/linux: Alt+Number&lt;/li&gt;
&lt;/ul&gt;

&lt;hr /&gt;

&lt;h3 id=&quot;parameter-info&quot;&gt;Parameter Info&lt;/h3&gt;
&lt;p&gt;&lt;img src=&quot;/assets/44-parameterinfo.gif&quot; alt=&quot;Parameter Info&quot; /&gt;&lt;/p&gt;

&lt;p&gt;This is the same list of parameter names as the one that appears when you are writing a method call. It is useful when you want to see an existing method’s params.&lt;/p&gt;

&lt;p&gt;The Parameter under your cursor will be in yellow.
If nothing is in yellow, that means that the method call is not valid, probably something that is not casted right (e.g. a float in an int param).&lt;/p&gt;

&lt;p&gt;When you are writing a method call and you dismiss it by accident, like I usually do, you can also type a comma (,) to trigger the parameter info.&lt;/p&gt;

&lt;p style=&quot;margin-bottom:0.25em&quot;&gt;Shortcut :&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Mac: Cmd+P&lt;/li&gt;
  &lt;li&gt;windows/linux: Ctrl+P&lt;/li&gt;
&lt;/ul&gt;

&lt;hr /&gt;

&lt;h3 id=&quot;the-switcher&quot;&gt;The Switcher&lt;/h3&gt;
&lt;p&gt;&lt;img src=&quot;/assets/46-switcher.gif&quot; alt=&quot;The Switcher&quot; /&gt;&lt;/p&gt;

&lt;p&gt;So this thing is pretty much the alt+tab / cmd+tab of the IDE. It allows you to navigate to a tab or a panel.&lt;/p&gt;

&lt;p&gt;Once it is opened, as long as you hold the ctrl key, you can navigate quickly by using the number or letter shortcut. You can also close a tab or a panel by pressing backspace when it is selected.&lt;/p&gt;

&lt;p&gt;Shortcut: Ctrl+Tab&lt;/p&gt;

&lt;hr /&gt;

&lt;h3 id=&quot;context-info&quot;&gt;Context Info&lt;/h3&gt;
&lt;p&gt;&lt;img src=&quot;/assets/47-contextinfo.gif&quot; alt=&quot;Context Info&quot; /&gt;&lt;/p&gt;

&lt;p&gt;So this will show you where you are when your scope definition is out of the scrolling area. Usually, this will be the name of the class or inner class  but it might also be the current method name.&lt;/p&gt;

&lt;p&gt;Its better use, IMO, is to get a quick look at what the current class extends or implements.&lt;/p&gt;

&lt;p&gt;It also works in xml files.&lt;/p&gt;

&lt;p&gt;Shortcut: Ctrl+Shift+Q&lt;/p&gt;
</description>
        <pubDate>Mon, 09 Feb 2015 18:10:00 -0500</pubDate>
        <link>http://www.developerphil.com/android-studio-tips-of-the-day-roundup-5/</link>
        <guid isPermaLink="true">http://www.developerphil.com/android-studio-tips-of-the-day-roundup-5/</guid>
        
        
      </item>
    
      <item>
        <title>Android Studio Tips Of the Day - Roundup #4 </title>
        <description>&lt;p&gt;This is the fourth roundup of my Android Studio Daily Tips that I post on &lt;a href=&quot;https://plus.google.com/+PhilippeBreault/&quot;&gt;Google+&lt;/a&gt;&lt;br /&gt;
You can take a look at the previous post &lt;a href=&quot;/android-studio-tips-of-the-day-roundup-3/&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;h4 id=&quot;about-keymaps&quot;&gt;About Keymaps&lt;/h4&gt;

&lt;p&gt;Android Studio provides different keymaps (the mapping between shortcut keys and an action).
You can see which keymap you are using in &lt;em&gt;Settings-&amp;gt;Keymap&lt;/em&gt;.&lt;/p&gt;

&lt;p style=&quot;margin-bottom:0.25em&quot;&gt;It wouldn’t be practical to list the shortcuts for every keymap so the following will be used:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Windows: Default&lt;/li&gt;
  &lt;li&gt;Linux: Default&lt;/li&gt;
  &lt;li&gt;OSX: Mac OSX 10.5+&lt;/li&gt;
&lt;/ul&gt;

&lt;hr /&gt;

&lt;h3 id=&quot;analyze-data-flow-to-here&quot;&gt;Analyze Data flow to Here&lt;/h3&gt;
&lt;p&gt;&lt;img src=&quot;/assets/31-analyzedataflow.gif&quot; alt=&quot;Analyze Data flow to Here&quot; /&gt;&lt;/p&gt;

&lt;p&gt;This will take the current variable, parameter or field and show you the path it has taken to get here!
This is very useful when you are entering an unfamiliar place in the code base and you want to understand how this parameter got there.&lt;/p&gt;

&lt;p&gt;There is also the reverse operation “Analyze Data Flow from Here” that will show you where your variable, field or return type will end up.&lt;/p&gt;

&lt;p style=&quot;margin-bottom:0.25em&quot;&gt;Shortcut : There is no keyboard shortcut for this…&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Menu: Analyze → Analyze Data Flow to Here&lt;/li&gt;
  &lt;li&gt;Find action: Analyze Data Flow to Here&lt;/li&gt;
&lt;/ul&gt;

&lt;hr /&gt;

&lt;h3 id=&quot;sublime-text-multi-selection&quot;&gt;Sublime Text Multi Selection&lt;/h3&gt;
&lt;p&gt;&lt;img src=&quot;/assets/32-multiselection.gif&quot; alt=&quot;Sublime Text Multi Selection&quot; /&gt;&lt;/p&gt;

&lt;p&gt;This one is particularly nice!&lt;br /&gt;
It will take the current selection, select the next occurrence and add a cursor there.
This means that you can have multiple cursors in the same file!
Everything you type will be written at each cursor.&lt;/p&gt;

&lt;p style=&quot;margin-bottom:0.25em&quot;&gt;Shortcut :&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Mac : Ctrl+G&lt;/li&gt;
  &lt;li&gt;Windows/Linux: Alt+J&lt;/li&gt;
&lt;/ul&gt;

&lt;hr /&gt;

&lt;h3 id=&quot;column-selection&quot;&gt;Column Selection&lt;/h3&gt;

&lt;p&gt;&lt;img src=&quot;/assets/33-columnselection.gif&quot; alt=&quot;Column Selection&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Enable column selections, also known as block selection.
Basically, if you select down, it will go down and not bother wrapping to the end of the line.&lt;/p&gt;

&lt;p&gt;This will also put a cursor after each line of the block selection from where you can type.&lt;/p&gt;

&lt;p style=&quot;margin-bottom:0.25em&quot;&gt;Shortcut :&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Mouse: Alt+MouseDrag&lt;/li&gt;
  &lt;li&gt;Mac : Cmd+Shift+8&lt;/li&gt;
  &lt;li&gt;Windows/Linux: Shift+Alt+Insert&lt;/li&gt;
&lt;/ul&gt;

&lt;hr /&gt;

&lt;h2 id=&quot;postfix-completion&quot;&gt;Postfix Completion&lt;/h2&gt;
&lt;p&gt;&lt;img src=&quot;/assets/33-postfixcompletion.gif&quot; alt=&quot;Postfix Completion&quot; /&gt;&lt;/p&gt;

&lt;p&gt;This one is not very intuitive but still pretty powerful.
Basically, it is a way to wrap the current statement in something else without having to press the left key a bunch of times to get there.&lt;/p&gt;

&lt;p&gt;E.g. to iterate a list, you could go “myList.for”, press tab and it would generate the for loop for you.&lt;/p&gt;

&lt;p&gt;You can get a list of what you can type by typing a dot after a statement and looking through the options after all the possible completions.&lt;/p&gt;

&lt;p style=&quot;margin-bottom:0.25em&quot;&gt;Some of my personal favorites:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;.for (for a foreach)&lt;/li&gt;
  &lt;li&gt;.format (wraps a string in String.format())&lt;/li&gt;
  &lt;li&gt;.cast (wraps a statement in a type cast)&lt;/li&gt;
&lt;/ul&gt;

&lt;hr /&gt;

&lt;h3 id=&quot;compare-with-clipboard&quot;&gt;Compare With Clipboard&lt;/h3&gt;
&lt;p&gt;&lt;img src=&quot;/assets/34-comparewithclipboard.gif&quot; alt=&quot;Compare With Clipboard&quot; /&gt;&lt;/p&gt;

&lt;p&gt;This will take the current selection and do a diff with the content of your clipboard.&lt;/p&gt;

&lt;p style=&quot;margin-bottom:0.25em&quot;&gt;Shortcut:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Mouse: right-click the selection and select &lt;em&gt;Compare With Clipboard&lt;/em&gt;&lt;/li&gt;
  &lt;li&gt;Find action: &lt;em&gt;compare with clipboard&lt;/em&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;hr /&gt;

&lt;h3 id=&quot;stop-process&quot;&gt;Stop Process&lt;/h3&gt;
&lt;p&gt;&lt;img src=&quot;/assets/35-stoprocess.gif&quot; alt=&quot;Stop Process&quot; /&gt;&lt;/p&gt;

&lt;p&gt;This will stop the currently running task or show a list of possible tasks to stop if there is more than one.&lt;/p&gt;

&lt;p&gt;Pretty useful to stop debugging or abort a build.&lt;/p&gt;

&lt;p style=&quot;margin-bottom:0.25em&quot;&gt;Shortcut :&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Mac : Cmd+F2&lt;/li&gt;
  &lt;li&gt;Windows/Linux: Ctrl+F2&lt;/li&gt;
&lt;/ul&gt;

&lt;hr /&gt;

&lt;h3 id=&quot;show-execution-point&quot;&gt;Show Execution Point&lt;/h3&gt;
&lt;p&gt;&lt;img src=&quot;/assets/36-executionpoint.gif&quot; alt=&quot;Show Execution Point&quot; /&gt;&lt;/p&gt;

&lt;p&gt;This will put the cursor back to where you are debugging right now.&lt;/p&gt;

&lt;p style=&quot;margin-bottom:0.25em&quot;&gt;The usual case is:&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;You break somewhere&lt;/li&gt;
  &lt;li&gt;You start looking around in this file and then a bunch of other files&lt;/li&gt;
  &lt;li&gt;You invoke this shortcut to return exactly to where you were in your step-by-step debugging session&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Shortcut (when debugging) : Alt+F10&lt;/p&gt;

&lt;hr /&gt;

&lt;h3 id=&quot;vcs-operations-popup&quot;&gt;VCS Operations Popup&lt;/h3&gt;
&lt;p&gt;&lt;img src=&quot;/assets/37-vcspopup.gif&quot; alt=&quot;VCS Operations Popup&quot; /&gt;&lt;/p&gt;

&lt;p&gt;This will show you the most frequent version control operations.
If your project is not under git or another sytem, it will at least give you a local history maintained by Android Studio.&lt;/p&gt;

&lt;p style=&quot;margin-bottom:0.25em&quot;&gt;Shortcut :&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Mac: Ctrl+V&lt;/li&gt;
  &lt;li&gt;Windows/Linux: Alt+`&lt;/li&gt;
&lt;/ul&gt;

&lt;hr /&gt;

&lt;h3 id=&quot;compare-with-branch-git&quot;&gt;Compare With Branch (Git)&lt;/h3&gt;
&lt;p&gt;&lt;img src=&quot;/assets/38-comparewithbranch.gif&quot; alt=&quot;Compare With Branch (Git)&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Assuming that your project is under Git, you can compare the current file or folder with another branch.
Pretty useful to get an idea of how much you have diverged from your main branch.&lt;/p&gt;

&lt;p style=&quot;margin-bottom:0.25em&quot;&gt;Shortcut :&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Menu (for git): VCS -&amp;gt; Git -&amp;gt; Compare With Branch&lt;/li&gt;
  &lt;li&gt;Find Actions: Compare With Branch&lt;/li&gt;
&lt;/ul&gt;
</description>
        <pubDate>Mon, 02 Feb 2015 18:05:00 -0500</pubDate>
        <link>http://www.developerphil.com/android-studio-tips-of-the-day-roundup-4/</link>
        <guid isPermaLink="true">http://www.developerphil.com/android-studio-tips-of-the-day-roundup-4/</guid>
        
        
      </item>
    
      <item>
        <title>Android Studio Tips Of the Day - Roundup #3</title>
        <description>&lt;p&gt;This is the third roundup of my Android Studio Daily Tips that I post on &lt;a href=&quot;https://plus.google.com/+PhilippeBreault/&quot;&gt;Google+&lt;/a&gt;&lt;br /&gt;
You can take a look at the previous post &lt;a href=&quot;/android-studio-tips-of-the-day-roundup-2/&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;h4 id=&quot;about-keymaps&quot;&gt;About Keymaps&lt;/h4&gt;

&lt;p&gt;Android Studio provides different keymaps (the mapping between shortcut keys and an action).
You can see which keymap you are using in &lt;em&gt;Settings-&amp;gt;Keymap&lt;/em&gt;.&lt;/p&gt;

&lt;p style=&quot;margin-bottom:0.25em&quot;&gt;It wouldn’t be practical to list the shortcuts for every keymap so the following will be used:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Windows: Default&lt;/li&gt;
  &lt;li&gt;Linux: Default&lt;/li&gt;
  &lt;li&gt;OSX: Mac OSX 10.5+&lt;/li&gt;
&lt;/ul&gt;

&lt;hr /&gt;

&lt;h3 id=&quot;toggle-breakpoints&quot;&gt;Toggle Breakpoints&lt;/h3&gt;

&lt;p&gt;&lt;img src=&quot;/assets/21-togglebreakpoints.gif&quot; alt=&quot;Expand Shrink Selection&quot; /&gt;&lt;/p&gt;

&lt;p&gt;The next few tips will be about debugging. So let’s start with the most basic one: adding a good old breakpoint!!
I am pretty sure that by now you have debugged an app and know how to toggle it by left-clicking in the left gutter.
Here is the correct shortcut to toggle it without your mouse.&lt;/p&gt;

&lt;p style=&quot;margin-bottom:0.25em&quot;&gt;Shortcut:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;OSX: Cmd+F8&lt;/li&gt;
  &lt;li&gt;Windows/Linux: Ctrl+F8&lt;/li&gt;
&lt;/ul&gt;

&lt;hr /&gt;

&lt;h3 id=&quot;conditional-breakpoints&quot;&gt;Conditional Breakpoints&lt;/h3&gt;

&lt;p&gt;&lt;img src=&quot;/assets/22-conditionalbreakpoint.gif&quot; alt=&quot;Expand Shrink Selection&quot; /&gt;&lt;/p&gt;

&lt;p&gt;In a nutshell, only do break when a certain condition is met. You can enter any java expression that returns a boolean based on the current scope.
And do enjoy the fact that the condition textbox supports code completion!&lt;/p&gt;

&lt;p style=&quot;margin-bottom:0.25em&quot;&gt;Shortcut:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Right click on a breakpoint and enter a condition.&lt;/li&gt;
&lt;/ul&gt;

&lt;hr /&gt;

&lt;h3 id=&quot;logging-breakpoints&quot;&gt;Logging Breakpoints&lt;/h3&gt;

&lt;p&gt;&lt;img src=&quot;/assets/23-loggingbreakpoints.gif&quot; alt=&quot;Logging Breakpoints&quot; /&gt;&lt;/p&gt;

&lt;p&gt;This is a breakpoint that logs stuff instead of breaking.
This can be useful when you want to log some stuff right now but cannot or don’t want to redeploy with logging code added.&lt;/p&gt;

&lt;p style=&quot;margin-bottom:0.25em&quot;&gt;Shortcut:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Right click on a breakpoint, uncheck &lt;em&gt;Suspend&lt;/em&gt; and type your message in “Log evaluated Expression”&lt;/li&gt;
&lt;/ul&gt;

&lt;hr /&gt;

&lt;h3 id=&quot;temporary-breakpoints&quot;&gt;Temporary Breakpoints&lt;/h3&gt;

&lt;p&gt;&lt;img src=&quot;/assets/24-temporarybreakpoints.gif&quot; alt=&quot;Temporary Breakpoints&quot; /&gt;&lt;/p&gt;

&lt;p&gt;This is a way to add a breakpoint that will be removed automatically the first time you hit it.&lt;/p&gt;

&lt;p style=&quot;margin-bottom:0.25em&quot;&gt;Shortcut:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Mouse: Alt+LeftClick in the left gutter&lt;/li&gt;
  &lt;li&gt;Mac: Cmd+Alt+Shift+F8&lt;/li&gt;
  &lt;li&gt;Windows/Linux: Ctrl+Alt+Shift+F8&lt;/li&gt;
&lt;/ul&gt;

&lt;hr /&gt;

&lt;h3 id=&quot;disable-breakpoints&quot;&gt;Disable Breakpoints&lt;/h3&gt;

&lt;p&gt;&lt;img src=&quot;/assets/25-disablebreakpoint.gif&quot; alt=&quot;Expand Shrink Selection&quot; /&gt;&lt;/p&gt;

&lt;p&gt;This will disable the breakpoint. Particularly useful when you have some complicated conditional or logging breakpoint that you don’t need right now but don’t want to recreate next time.&lt;/p&gt;

&lt;p style=&quot;margin-bottom:0.25em&quot;&gt;Shortcut:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Mouse: Alt+LeftClick on an existing breakpoint in the left gutter&lt;/li&gt;
  &lt;li&gt;There is no keyboard shortcut but you can create one if you use it often enough.&lt;/li&gt;
&lt;/ul&gt;

&lt;hr /&gt;

&lt;h3 id=&quot;attach-debugger&quot;&gt;Attach Debugger&lt;/h3&gt;

&lt;p&gt;&lt;img src=&quot;/assets/26-attachdebugger.gif&quot; alt=&quot;Attach Debugger&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Start debugger even if you didn’t start the app in debug mode.
This is very useful since you don’t have to redeploy the app to start debugging.
It is pretty useful also when somebody is testing the app, encounters a bug and give you his device.&lt;/p&gt;

&lt;p style=&quot;margin-bottom:0.25em&quot;&gt;Shortcut:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Mouse: click on its icon or select the menu item &lt;em&gt;Build → Attach to Android Process&lt;/em&gt;&lt;/li&gt;
  &lt;li&gt;There is no keyboard shortcut but you should create one!&lt;/li&gt;
&lt;/ul&gt;

&lt;hr /&gt;

&lt;h3 id=&quot;evaluate-expression&quot;&gt;Evaluate Expression&lt;/h3&gt;

&lt;p&gt;&lt;img src=&quot;/assets/27-evaluateexpression.gif&quot; alt=&quot;Evaluate Expression&quot; /&gt;&lt;/p&gt;

&lt;p&gt;This is used to inspect a variable’s content and evaluate pretty much any valid java expression right there, right now.
Just be aware that if you are mutating state, it will stay that way when you resume the execution of the program.&lt;/p&gt;

&lt;p style=&quot;margin-bottom:0.25em&quot;&gt;Shortcut:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Alt+F8&lt;/li&gt;
&lt;/ul&gt;

&lt;hr /&gt;

&lt;h3 id=&quot;inspect-variable&quot;&gt;Inspect Variable&lt;/h3&gt;

&lt;p&gt;&lt;img src=&quot;/assets/28-mouse_evaluate_expression.gif&quot; alt=&quot;Inspect Variable&quot; /&gt;&lt;/p&gt;

&lt;p&gt;This evaluates an expression without opening the &lt;em&gt;Evaluate Expression&lt;/em&gt; dialog&lt;/p&gt;

&lt;p style=&quot;margin-bottom:0.25em&quot;&gt;Shortcut:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Alt+LeftClick on an expression&lt;/li&gt;
&lt;/ul&gt;

&lt;hr /&gt;

&lt;h3 id=&quot;mark-object&quot;&gt;Mark Object&lt;/h3&gt;

&lt;p&gt;&lt;img src=&quot;/assets/29-markobject.gif&quot; alt=&quot;Mark Object&quot; /&gt;&lt;/p&gt;

&lt;p&gt;During a debugging session, this will let you add a label to a particular object so that you can identify it later.
Very useful in those debugging sessions where you have a bunch of similar object and you want to know if it is the same one as before.&lt;/p&gt;

&lt;p style=&quot;margin-bottom:0.25em&quot;&gt;Shortcut (from the variables or watch panel):&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Mouse: right-click and select “Mark Object”&lt;/li&gt;
  &lt;li&gt;OSX : F3 with the object selected&lt;/li&gt;
  &lt;li&gt;Windows/Linux: F11 with the object selected&lt;/li&gt;
&lt;/ul&gt;

&lt;hr /&gt;

&lt;h3 id=&quot;analyze-stacktrace&quot;&gt;Analyze Stacktrace&lt;/h3&gt;

&lt;p&gt;&lt;img src=&quot;/assets/30-analyzestacktrace.gif&quot; alt=&quot;Analyze Stacktrace&quot; /&gt;&lt;/p&gt;

&lt;p&gt;This will take a stacktrace and make it clickable just as if it had been shown in logcat.
This is particularly useful when copying a stacktrace from a bug report or from a terminal.&lt;/p&gt;

&lt;p&gt;Additional tip:&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;You can also analyze a proguarded stack trace using the “ProGuard Unscramble Plugin”&lt;/li&gt;
&lt;/ul&gt;

&lt;p style=&quot;margin-bottom:0.25em&quot;&gt;Shortcut : There is no shortcut for this…&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Menu: Analyze → Analyze Stacktrace&lt;/li&gt;
  &lt;li&gt;Find action: analyze stacktrace&lt;/li&gt;
&lt;/ul&gt;
</description>
        <pubDate>Mon, 26 Jan 2015 19:00:00 -0500</pubDate>
        <link>http://www.developerphil.com/android-studio-tips-of-the-day-roundup-3/</link>
        <guid isPermaLink="true">http://www.developerphil.com/android-studio-tips-of-the-day-roundup-3/</guid>
        
        
      </item>
    
      <item>
        <title>Android Studio Tips Of the Day - Roundup #2</title>
        <description>&lt;p&gt;This is the second roundup of my Android Studio Daily Tips that I post on &lt;a href=&quot;https://plus.google.com/+PhilippeBreault/&quot;&gt;Google+&lt;/a&gt;&lt;br /&gt;
You can take a look at the previous post &lt;a href=&quot;/android-studio-tips-of-the-day-roundup-1/&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;h4 id=&quot;about-keymaps&quot;&gt;About Keymaps&lt;/h4&gt;

&lt;p&gt;Android Studio provides different keymaps (the mapping between shortcut keys and an action).
You can see which keymap you are using in &lt;em&gt;Settings-&amp;gt;Keymap&lt;/em&gt;.&lt;/p&gt;

&lt;p style=&quot;margin-bottom:0.25em&quot;&gt;It wouldn’t be practical to list the shortcuts for every keymap so the following will be used:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Windows: Default&lt;/li&gt;
  &lt;li&gt;Linux: Default&lt;/li&gt;
  &lt;li&gt;OSX: Mac OSX 10.5+&lt;/li&gt;
&lt;/ul&gt;

&lt;h3 id=&quot;duplicate-lines&quot;&gt;Duplicate Lines&lt;/h3&gt;

&lt;div class=&quot;shortcuts&quot;&gt;
  
  &lt;kbd class=&quot;icon-shortcut-apple&quot;&gt;cmd+d&lt;/kbd&gt;
  
  
  &lt;kbd class=&quot;icon-shortcut-windowslinux&quot;&gt;ctrl+d&lt;/kbd&gt;
  
&lt;/div&gt;

&lt;p&gt;Just as it says: it will copy the current line and paste it below without interfering with your clipboard. It can be pretty useful when it’s used with the move line shortcut!&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/11-duplicate_lines.gif&quot; alt=&quot;Android Studio Logo&quot; /&gt;&lt;/p&gt;

&lt;h3 id=&quot;expandshrink-selection&quot;&gt;Expand/Shrink Selection&lt;/h3&gt;
&lt;div class=&quot;shortcuts&quot;&gt;
  
  &lt;kbd class=&quot;icon-shortcut-apple&quot;&gt;alt+up/down&lt;/kbd&gt;
  
  
  &lt;kbd class=&quot;icon-shortcut-windowslinux&quot;&gt;ctrl+w / ctrl+shift+w&lt;/kbd&gt;
  
&lt;/div&gt;

&lt;p&gt;This will contextually expand the current selection. e.g. it will select the current variable, then the statement, then the method, etc.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/12-expand_shrink_selection.gif&quot; alt=&quot;Android Studio Logo&quot; /&gt;&lt;/p&gt;

&lt;h3 id=&quot;surround-with&quot;&gt;Surround with&lt;/h3&gt;
&lt;div class=&quot;shortcuts&quot;&gt;
  
  &lt;kbd class=&quot;icon-shortcut-apple&quot;&gt;cmd+alt+t&lt;/kbd&gt;
  
  
  &lt;kbd class=&quot;icon-shortcut-windowslinux&quot;&gt;ctrl+alt+t&lt;/kbd&gt;
  
&lt;/div&gt;

&lt;p&gt;This can be used to wrap a block of code in some structure. Usually an if statement, a loop, a try-catch or a runnable.&lt;/p&gt;

&lt;p&gt;If you have nothing selected, it will wrap the current line.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/13-surround_with.gif&quot; alt=&quot;Android Studio Logo&quot; /&gt;&lt;/p&gt;

&lt;h3 id=&quot;recents&quot;&gt;Recents&lt;/h3&gt;
&lt;div class=&quot;shortcuts&quot;&gt;
  
  &lt;kbd class=&quot;icon-shortcut-apple&quot;&gt;cmd+e&lt;/kbd&gt;
  
  
  &lt;kbd class=&quot;icon-shortcut-windowslinux&quot;&gt;ctrl+e&lt;/kbd&gt;
  
&lt;/div&gt;

&lt;p&gt;Using this, you get a searchable list of the most recently consulted files!
&lt;img src=&quot;/assets/14-recents.gif&quot; alt=&quot;Android Studio Logo&quot; /&gt;&lt;/p&gt;

&lt;h3 id=&quot;live-templates&quot;&gt;Live Templates&lt;/h3&gt;
&lt;div class=&quot;shortcuts&quot;&gt;
  
  &lt;kbd class=&quot;icon-shortcut-apple&quot;&gt;cmd+j &lt;/kbd&gt;
  
  
  &lt;kbd class=&quot;icon-shortcut-windowslinux&quot;&gt;ctrl+j&lt;/kbd&gt;
  
&lt;/div&gt;

&lt;p&gt;The live template is a way to quickly insert a snippet of code. The interesting thing with live templates is that they can be parameterized with sensible defaults and guide you through the parameters when you insert it.&lt;/p&gt;

&lt;p style=&quot;margin-bottom:0.25em&quot;&gt;Additional Tip:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;You don’t need to invoke the shortcut if you know the abbreviation. You only need to type it and complete using the &lt;em&gt;Tab&lt;/em&gt; key.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;img src=&quot;/assets/15-live_templates.gif&quot; alt=&quot;Android Studio Logo&quot; /&gt;&lt;/p&gt;

&lt;h3 id=&quot;move-methods&quot;&gt;Move Methods&lt;/h3&gt;

&lt;div class=&quot;shortcuts&quot;&gt;
  
  &lt;kbd class=&quot;icon-shortcut-apple&quot;&gt;cmd+alt+up/down&lt;/kbd&gt;
  
  
  &lt;kbd class=&quot;icon-shortcut-windowslinux&quot;&gt;ctrl+shift+up/down&lt;/kbd&gt;
  
&lt;/div&gt;

&lt;p&gt;This is like the &lt;em&gt;Move Line&lt;/em&gt; shortcut but applied to whole methods.
It allows you to move a method below or above another one without copy-pasting.&lt;/p&gt;

&lt;p&gt;The real name of this action is &lt;em&gt;Move Statement&lt;/em&gt;. Meaning that it moves any kind of statement. E.g. you can reorder fields and inner classes.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/15-movemethods.gif&quot; alt=&quot;Android Studio Logo&quot; /&gt;&lt;/p&gt;

&lt;h3 id=&quot;complete-statement&quot;&gt;Complete Statement&lt;/h3&gt;
&lt;div class=&quot;shortcuts&quot;&gt;
  
  &lt;kbd class=&quot;icon-shortcut-apple&quot;&gt;cmd+shift+enter&lt;/kbd&gt;
  
  
  &lt;kbd class=&quot;icon-shortcut-windowslinux&quot;&gt;ctrl+shift+enter&lt;/kbd&gt;
  
&lt;/div&gt;

&lt;p style=&quot;margin-bottom:0.25em&quot;&gt;This will generate the missing code to complete a statement
The usual use cases are:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Add a semicolon at the end of the line, even if you are not at the end of the line&lt;/li&gt;
  &lt;li&gt;Add the parentheses and curly braces after an if, while or for&lt;/li&gt;
  &lt;li&gt;Add the curly braces after a method declaration&lt;/li&gt;
&lt;/ul&gt;

&lt;p style=&quot;margin-bottom:0.25em&quot;&gt;Additional Tip:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;If a statement is already completed, it will go to the next line even if you are not at the last character of the current line.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;img src=&quot;/assets/16-completestatement.gif&quot; alt=&quot;Android Studio Logo&quot; /&gt;&lt;/p&gt;

&lt;h3 id=&quot;last-edit-location&quot;&gt;Last Edit Location&lt;/h3&gt;
&lt;div class=&quot;shortcuts&quot;&gt;
  
  &lt;kbd class=&quot;icon-shortcut-apple&quot;&gt;cmd+shift+backspace&lt;/kbd&gt;
  
  
  &lt;kbd class=&quot;icon-shortcut-windowslinux&quot;&gt;ctrl+shift+backspace&lt;/kbd&gt;
  
&lt;/div&gt;

&lt;p&gt;This will make you navigate through the last changes you made.
This is different from clicking the back arrow in the toolbar in that it makes you travel within your edition history and not your navigation history.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/17-navigate-previous-changes.gif&quot; alt=&quot;Android Studio Logo&quot; /&gt;&lt;/p&gt;

&lt;h3 id=&quot;join-lines-and-literals&quot;&gt;Join Lines and Literals&lt;/h3&gt;

&lt;div class=&quot;shortcuts&quot;&gt;
  
  &lt;kbd class=&quot;icon-shortcut-apple&quot;&gt;ctrl+shift+j&lt;/kbd&gt;
  
  
  &lt;kbd class=&quot;icon-shortcut-windowslinux&quot;&gt;ctrl+shift+j&lt;/kbd&gt;
  
&lt;/div&gt;

&lt;p style=&quot;margin-bottom:0.25em&quot;&gt;This is doing more than simulating the delete key at the end of the line!
It will preserve formatting rules and it will also:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Merge two comment lines and remove the unused //&lt;/li&gt;
  &lt;li&gt;Merge multiline strings, removing the + signs and the double-quotes&lt;/li&gt;
  &lt;li&gt;Join fields and assignments&lt;/li&gt;
&lt;/ul&gt;

&lt;p style=&quot;margin-bottom:0.25em&quot;&gt;Additional Tip:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;If you select a string that spans multiple lines, it will merge it on a single one.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;img src=&quot;/assets/18-joinlines.gif&quot; alt=&quot;Android Studio Logo&quot; /&gt;&lt;/p&gt;

&lt;h3 id=&quot;select-in&quot;&gt;Select In&lt;/h3&gt;

&lt;div class=&quot;shortcuts&quot;&gt;
  
  &lt;kbd class=&quot;icon-shortcut-apple&quot;&gt;alt+f1&lt;/kbd&gt;
  
  
  &lt;kbd class=&quot;icon-shortcut-windowslinux&quot;&gt;alt+f1&lt;/kbd&gt;
  
&lt;/div&gt;

&lt;p&gt;Takes the current file and asks you where to select it.
The most useful shortcuts IMHO are to open in the project structure or in your file explorer.
Note that each action is prefixed by a number or a letter, this is the shortcut to invoke it quickly.&lt;/p&gt;

&lt;p&gt;Usually, I’ll go Alt+F1 then Enter to open in the project view and Alt+F1+8 to reveal the file in Finder on the Mac.&lt;/p&gt;

&lt;p&gt;You can invoke this from a file or directly from the project view.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/19-select-in.gif&quot; alt=&quot;Android Studio Logo&quot; /&gt;&lt;/p&gt;

&lt;h3 id=&quot;unwrapremove&quot;&gt;Unwrap/Remove&lt;/h3&gt;

&lt;div class=&quot;shortcuts&quot;&gt;
  
  &lt;kbd class=&quot;icon-shortcut-apple&quot;&gt;cmd+shift+delete&lt;/kbd&gt;
  
  
  &lt;kbd class=&quot;icon-shortcut-windowslinux&quot;&gt;ctrl+shift+delete&lt;/kbd&gt;
  
&lt;/div&gt;

&lt;p&gt;This will remove the surrounding code. It could be to remove an if statement, a while, a try/catch or even a runnable.
This is exactly the opposite of the &lt;em&gt;Surround With&lt;/em&gt; shortcut.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/20-unwrap.gif&quot; alt=&quot;Android Studio Logo&quot; /&gt;&lt;/p&gt;
</description>
        <pubDate>Thu, 18 Sep 2014 19:29:36 -0400</pubDate>
        <link>http://www.developerphil.com/android-studio-tips-of-the-day-roundup-2/</link>
        <guid isPermaLink="true">http://www.developerphil.com/android-studio-tips-of-the-day-roundup-2/</guid>
        
        
      </item>
    
      <item>
        <title>Android Studio Tips Of the Day - Roundup #1</title>
        <description>&lt;p&gt;Turns out that I am not that good at keeping a commitment. The &lt;a href=&quot;/android-studio-tips-tricks-moving-around/&quot;&gt;previous post&lt;/a&gt; was supposed to be a new series that I would contribute to but here we are, one year later!&lt;/p&gt;

&lt;p&gt;So I am starting this all over again! Instead I am doing a series of daily posts on Google+ and I will post recaps here, much like what &lt;a href=&quot;http://blog.danlew.net/2014/03/30/android-tips-round-up-part-1/&quot;&gt;Daniel Lew did&lt;/a&gt; a while back.&lt;/p&gt;

&lt;p&gt;Note that since I am starting a new series on G+, there will be some duplications with the previous post.&lt;/p&gt;

&lt;p&gt;If you want the most up to date tips, &lt;a href=&quot;https://plus.google.com/+PhilippeBreault/&quot;&gt;follow me on google+&lt;/a&gt; or subscribe to the &lt;a href=&quot;https://plus.google.com/communities/114791428968349268860&quot;&gt;Android Developer Tools Community&lt;/a&gt;. &lt;a href=&quot;https://github.com/pavlospt/Android-Studio-Tips-by-Philippe-Breault/wiki&quot;&gt;Pavlos-Petros Tournaris also collected all the current tips on github&lt;/a&gt;, So if you want a sneak peak at the content of the next blog posts, check it out!&lt;/p&gt;

&lt;h4 id=&quot;about-keymaps&quot;&gt;About Keymaps&lt;/h4&gt;

&lt;p&gt;Android Studio provides different keymaps (the mapping between shortcut keys and an action).
You can see which keymap you are using in &lt;em&gt;Settings-&amp;gt;Keymap&lt;/em&gt;.&lt;/p&gt;

&lt;p style=&quot;margin-bottom:0.25em&quot;&gt;It wouldn’t be practical to list the shortcuts for every keymap so the following will be used:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Windows: Default&lt;/li&gt;
  &lt;li&gt;Linux: Default&lt;/li&gt;
  &lt;li&gt;OSX: Mac OSX 10.5+&lt;/li&gt;
&lt;/ul&gt;

&lt;h3 id=&quot;highlight-all-the-things&quot;&gt;Highlight All the Things&lt;/h3&gt;

&lt;div class=&quot;shortcuts&quot;&gt;
  
  &lt;kbd class=&quot;icon-shortcut-apple&quot;&gt;cmd+shift+f7&lt;/kbd&gt;
  
  
  &lt;kbd class=&quot;icon-shortcut-windowslinux&quot;&gt;ctrl+shift+f7&lt;/kbd&gt;
  
&lt;/div&gt;

&lt;p&gt;This will highlight every occurrence of a symbol in the current file. This is more than some simple pattern matching, it will actually understand the current scope and  only highlight what is relevant.&lt;/p&gt;

&lt;p&gt;You can then navigate up or down using the shortcuts from &lt;em&gt;Edit → Find → Find Next/Previous&lt;/em&gt;&lt;/p&gt;

&lt;p style=&quot;margin-bottom:0.25em&quot;&gt;Additional tips:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Highlighting a “return” or a “throw” statement in a method will also highlight all the exit points of the method.&lt;/li&gt;
  &lt;li&gt;Highlighting the “extends” or the “implements” portion of the class definion will also highlight the methods that are overriden/implemented.&lt;/li&gt;
  &lt;li&gt;Highlighting an import will also highlight where it is used.&lt;/li&gt;
  &lt;li&gt;You can cancel the highlighting by pressing Escape.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;img src=&quot;/assets/01-highlight.gif&quot; alt=&quot;Android Studio Logo&quot; /&gt;&lt;/p&gt;

&lt;h3 id=&quot;move-between-methods-and-inner-classes&quot;&gt;Move Between Methods and Inner Classes&lt;/h3&gt;

&lt;div class=&quot;shortcuts&quot;&gt;
  
  &lt;kbd class=&quot;icon-shortcut-apple&quot;&gt;ctrl+up/down&lt;/kbd&gt;
  
  
  &lt;kbd class=&quot;icon-shortcut-windowslinux&quot;&gt;alt+up/down&lt;/kbd&gt;
  
&lt;/div&gt;

&lt;p&gt;This wil move your cursor to the name of the next method or class in the current file.&lt;/p&gt;

&lt;p&gt;If you are in the body of a method, going up will put the cursor on its name. This can be very useful because it puts you at the right place to refactor or find the usages of this method.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/02-move_between_methods.gif&quot; alt=&quot;Android Studio Logo&quot; /&gt;&lt;/p&gt;

&lt;h3 id=&quot;the-file-structure-popup&quot;&gt;The File Structure Popup&lt;/h3&gt;

&lt;div class=&quot;shortcuts&quot;&gt;
  
  &lt;kbd class=&quot;icon-shortcut-apple&quot;&gt;cmd+f12&lt;/kbd&gt;
  
  
  &lt;kbd class=&quot;icon-shortcut-windowslinux&quot;&gt;ctrl+f12&lt;/kbd&gt;
  
&lt;/div&gt;

&lt;p&gt;The idea here is to show an outline of the current class and navigate in it. The best thing about it is that you can filter using your keyboard. This is a very efficient way to go to a method you know by name.&lt;/p&gt;

&lt;p style=&quot;margin-bottom:0.25em&quot;&gt;Additional tips:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;You can use camel-case matching when typing to filter the list. Example: typing “oCr” would find “onCreate”&lt;/li&gt;
  &lt;li&gt;You can toggle a checkbox to also show anonymous classes. It could be useful in some cases like if you want to go directly to the onClick method in an OnClickListener.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;img src=&quot;/assets/03-filestructure.gif&quot; alt=&quot;Android Studio Logo&quot; /&gt;&lt;/p&gt;

&lt;h3 id=&quot;the-call-hierarchy-popup&quot;&gt;The Call Hierarchy Popup&lt;/h3&gt;

&lt;div class=&quot;shortcuts&quot;&gt;
  
  &lt;kbd class=&quot;icon-shortcut-apple&quot;&gt;ctrl+alt+h&lt;/kbd&gt;
  
  
  &lt;kbd class=&quot;icon-shortcut-windowslinux&quot;&gt;ctrl+alt+h&lt;/kbd&gt;
  
&lt;/div&gt;

&lt;p&gt;This will show you the possible paths between a method’s declaration and its invocations!&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/04-callinghierarchy.gif&quot; alt=&quot;Android Studio Logo&quot; /&gt;&lt;/p&gt;

&lt;h3 id=&quot;quick-definition-lookup&quot;&gt;Quick Definition Lookup&lt;/h3&gt;

&lt;div class=&quot;shortcuts&quot;&gt;
  
  &lt;kbd class=&quot;icon-shortcut-apple&quot;&gt;alt+space&lt;/kbd&gt;
  
  
  &lt;kbd class=&quot;icon-shortcut-windowslinux&quot;&gt;ctrl+shift+i&lt;/kbd&gt;
  
&lt;/div&gt;

&lt;p&gt;Ever wondered whats the implementation of a method or class but don’t want to lose your current context?
Use this shortcut to look it up in place.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/05-quickdefinition.gif&quot; alt=&quot;Android Studio Logo&quot; /&gt;&lt;/p&gt;

&lt;h3 id=&quot;collapse-expand-code-block&quot;&gt;Collapse Expand Code Block&lt;/h3&gt;

&lt;div class=&quot;shortcuts&quot;&gt;
  
  &lt;kbd class=&quot;icon-shortcut-apple&quot;&gt;alt+plus/minus&lt;/kbd&gt;
  
  
  &lt;kbd class=&quot;icon-shortcut-windowslinux&quot;&gt;ctrl+shift+plus/minus&lt;/kbd&gt;
  
&lt;/div&gt;

&lt;p&gt;The goal of this feature is to let you hide things you don’t care about at the moment.
In its simplest form, it will hide a whole code block (e.g. ignoring the import list when you open a new file). A more interesting use is that it will hide the boilerplate around simple anonymous inner classes and make it look like a lambda expression.&lt;/p&gt;

&lt;p style=&quot;margin-bottom:0.25em&quot;&gt;Additional tip:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;You can setup the default folding behaviour in the preferences at &lt;em&gt;Editor → Code Folding&lt;/em&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;img src=&quot;/assets/06-codefolding.gif&quot; alt=&quot;Android Studio Logo&quot; /&gt;&lt;/p&gt;

&lt;h3 id=&quot;bookmarks&quot;&gt;Bookmarks!&lt;/h3&gt;

&lt;h5 id=&quot;toggle-bookmark&quot;&gt;Toggle Bookmark&lt;/h5&gt;

&lt;div class=&quot;shortcuts&quot;&gt;
  
  &lt;kbd class=&quot;icon-shortcut-apple&quot;&gt;f3&lt;/kbd&gt;
  
  
  &lt;kbd class=&quot;icon-shortcut-windowslinux&quot;&gt;f11&lt;/kbd&gt;
  
&lt;/div&gt;

&lt;h5 id=&quot;toggle-bookmark-with-mnemonic&quot;&gt;Toggle Bookmark With Mnemonic&lt;/h5&gt;

&lt;div class=&quot;shortcuts&quot;&gt;
  
  &lt;kbd class=&quot;icon-shortcut-apple&quot;&gt;alt+f3&lt;/kbd&gt;
  
  
  &lt;kbd class=&quot;icon-shortcut-windowslinux&quot;&gt;ctrl+f11&lt;/kbd&gt;
  
&lt;/div&gt;

&lt;p&gt;If you assign a number, you can go back to the bookmark using this shortcut: ctrl+number&lt;/p&gt;

&lt;h5 id=&quot;show-bookmarks&quot;&gt;Show Bookmarks&lt;/h5&gt;

&lt;div class=&quot;shortcuts&quot;&gt;
  
  &lt;kbd class=&quot;icon-shortcut-apple&quot;&gt;cmd+f3&lt;/kbd&gt;
  
  
  &lt;kbd class=&quot;icon-shortcut-windowslinux&quot;&gt;shift+f11&lt;/kbd&gt;
  
&lt;/div&gt;

&lt;p&gt;&lt;img src=&quot;/assets/07-bookmarks.gif&quot; alt=&quot;Android Studio Logo&quot; /&gt;&lt;/p&gt;

&lt;h3 id=&quot;find-actions&quot;&gt;Find Actions&lt;/h3&gt;

&lt;div class=&quot;shortcuts&quot;&gt;
  
  &lt;kbd class=&quot;icon-shortcut-apple&quot;&gt;cmd+shift+a&lt;/kbd&gt;
  
  
  &lt;kbd class=&quot;icon-shortcut-windowslinux&quot;&gt;ctrl+shift+a&lt;/kbd&gt;
  
&lt;/div&gt;

&lt;p&gt;You can invoke any menu or action known to Android Studio by its name! This is pretty useful for commands that you use once in a while but don’t have a shortcut for.&lt;/p&gt;

&lt;p style=&quot;margin-bottom:0.25em&quot;&gt;Additional tip:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;If there is a shortcut associated to the action, it will be shown by its side&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;img src=&quot;/assets/08-findaction.gif&quot; alt=&quot;Android Studio Logo&quot; /&gt;&lt;/p&gt;

&lt;h3 id=&quot;move-lines-updown&quot;&gt;Move Lines Up/Down&lt;/h3&gt;

&lt;div class=&quot;shortcuts&quot;&gt;
  
  &lt;kbd class=&quot;icon-shortcut-apple&quot;&gt;alt+shift+up/down&lt;/kbd&gt;
  
  
  &lt;kbd class=&quot;icon-shortcut-windowslinux&quot;&gt;alt+shift+up/down&lt;/kbd&gt;
  
&lt;/div&gt;

&lt;p&gt;Yeah. This will move lines up or down. Not much more to say. Enjoy!&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/09-movelines.gif&quot; alt=&quot;Android Studio Logo&quot; /&gt;&lt;/p&gt;

&lt;h3 id=&quot;delete-line&quot;&gt;Delete Line&lt;/h3&gt;

&lt;div class=&quot;shortcuts&quot;&gt;
  
  &lt;kbd class=&quot;icon-shortcut-apple&quot;&gt;cmd+backspace&lt;/kbd&gt;
  
  
  &lt;kbd class=&quot;icon-shortcut-windowslinux&quot;&gt;ctrl+y&lt;/kbd&gt;
  
&lt;/div&gt;

&lt;p&gt;It deletes the current line or selection.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/10-deleteline.gif&quot; alt=&quot;Android Studio Logo&quot; /&gt;&lt;/p&gt;
</description>
        <pubDate>Sat, 06 Sep 2014 12:03:09 -0400</pubDate>
        <link>http://www.developerphil.com/android-studio-tips-of-the-day-roundup-1/</link>
        <guid isPermaLink="true">http://www.developerphil.com/android-studio-tips-of-the-day-roundup-1/</guid>
        
        
      </item>
    
      <item>
        <title>Android Studio Tips &amp; Tricks: Moving Around</title>
        <description>&lt;p class=&quot;size-medium wp-image-300 alignright&quot;&gt;&lt;a href=&quot;http://developer.android.com/sdk/installing/studio.html&quot;&gt;&lt;img src=&quot;/assets/android_studio_logo-300x300.png&quot; alt=&quot;Android Studio Logo&quot; /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;There are two things that you should know about me:&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;I am an IDE enthusiast&lt;/li&gt;
  &lt;li&gt;I am a productivity geek&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;So two years ago, when I switched to &lt;a href=&quot;http://www.jetbrains.com/idea/features/android.html&quot;&gt;Intellij IDEA&lt;/a&gt;, on which &lt;a href=&quot;http://developer.android.com/sdk/installing/studio.html&quot;&gt;Android Studio&lt;/a&gt; is based, I spent a lot of time looking for shortcuts and techniques to become more productive. Since you are here, I suspect you might be doing the same so I’ll try to make it easier and faster for you!&lt;/p&gt;

&lt;p&gt;In this series, we will go from very basic productivity tricks that everyone should know to more advanced topics in Android Studio.&lt;/p&gt;

&lt;h4 id=&quot;about-keymaps&quot;&gt;About Keymaps&lt;/h4&gt;

&lt;p&gt;Android Studio provides different keymaps (the mapping between shortcut keys and an action).
You can see which keymap you are using in &lt;em&gt;Settings-&amp;gt;Keymap&lt;/em&gt;.&lt;/p&gt;

&lt;p style=&quot;margin-bottom:0.25em&quot;&gt;It wouldn’t be practical to list the shortcuts for every keymap so the following will be used:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Windows: Default&lt;/li&gt;
  &lt;li&gt;Linux: Default&lt;/li&gt;
  &lt;li&gt;OSX: Mac OSX 10.5+ (not the default one! Jetbrains and I highly suggest that you use this one!)&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;moving-around&quot;&gt;Moving Around&lt;/h2&gt;

&lt;p&gt;We spend a lot of time navigating in our code base, let’s try to do it more efficiently.&lt;/p&gt;

&lt;h3 id=&quot;opening-classfilesymbol&quot;&gt;Opening Class/File/Symbol&lt;/h3&gt;

&lt;h5 id=&quot;open-class&quot;&gt;Open class&lt;/h5&gt;

&lt;div class=&quot;shortcuts&quot;&gt;
  
  &lt;kbd class=&quot;icon-shortcut-apple&quot;&gt;cmd+o&lt;/kbd&gt;
  
  
  &lt;kbd class=&quot;icon-shortcut-windowslinux&quot;&gt;ctrl+n&lt;/kbd&gt;
  
&lt;/div&gt;

&lt;p&gt;Imagine that you must go to a class named “MainActivity”, just use this shortcut and start typing “MainA”.&lt;/p&gt;

&lt;h5 id=&quot;open-file&quot;&gt;Open File&lt;/h5&gt;
&lt;div class=&quot;shortcuts&quot;&gt;
  
  &lt;kbd class=&quot;icon-shortcut-apple&quot;&gt;cmd+shift+o&lt;/kbd&gt;
  
  
  &lt;kbd class=&quot;icon-shortcut-windowslinux&quot;&gt;ctrl+shift+n&lt;/kbd&gt;
  
&lt;/div&gt;

&lt;p&gt;Works like the “Open Class” shortcut but on every files in your project. It is very useful to open your AndroidManifest.xml or anything that sits in the &lt;em&gt;res/&lt;/em&gt; or &lt;em&gt;assets/&lt;/em&gt; folder.&lt;/p&gt;

&lt;h5 id=&quot;open-symbol&quot;&gt;Open Symbol&lt;/h5&gt;

&lt;div class=&quot;shortcuts&quot;&gt;
  
  &lt;kbd class=&quot;icon-shortcut-apple&quot;&gt;cmd+alt+o&lt;/kbd&gt;
  
  
  &lt;kbd class=&quot;icon-shortcut-windowslinux&quot;&gt;alt+shift+n&lt;/kbd&gt;
  
&lt;/div&gt;

&lt;p&gt;A very powerful but little less known variation of the previous tips: You can use this to go directly to a method or field by searching its name!&lt;/p&gt;

&lt;p&gt;For example, if you know that you have a method named getFormattedDate() somewhere in your project, you can type it in the Open Symbol dialog to go directly to it.&lt;/p&gt;

&lt;h5 id=&quot;tips&quot;&gt;Tips&lt;/h5&gt;

&lt;h6 id=&quot;partial-matching&quot;&gt;Partial Matching&lt;/h6&gt;

&lt;p&gt;You can enter incomplete strings and it will work. For example. if you are searching for a class named “ItemDetailFragment”, you can actually type “IDF” and it will find it.&lt;/p&gt;

&lt;h6 id=&quot;line-number&quot;&gt;Line Number&lt;/h6&gt;

&lt;p&gt;Imagine that your colleague just told you that the juicy part is in &lt;em&gt;ExcitingClass&lt;/em&gt; at line 23. You can open the file directly by appending a “:” to the class name in the &lt;em&gt;Open Class&lt;/em&gt; dialog. e.g.:&lt;/p&gt;

&lt;p&gt;&lt;code class=&quot;highlighter-rouge&quot;&gt;ExcitingClass:22&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;You can also combine it with partial matching and type something like:&lt;/p&gt;

&lt;p&gt;&lt;code class=&quot;highlighter-rouge&quot;&gt;EC:22&lt;/code&gt;&lt;/p&gt;

&lt;h3 id=&quot;recent-files&quot;&gt;Recent Files&lt;/h3&gt;

&lt;h5 id=&quot;recently-opened-files&quot;&gt;Recently opened files&lt;/h5&gt;

&lt;div class=&quot;shortcuts&quot;&gt;
  
  &lt;kbd class=&quot;icon-shortcut-apple&quot;&gt;cmd+e&lt;/kbd&gt;
  
  
  &lt;kbd class=&quot;icon-shortcut-windowslinux&quot;&gt;ctrl+e&lt;/kbd&gt;
  
&lt;/div&gt;

&lt;p&gt;This will show a popup listing the files you navigated to previously.&lt;/p&gt;

&lt;h5 id=&quot;recently-edited-files&quot;&gt;Recently edited files&lt;/h5&gt;

&lt;div class=&quot;shortcuts&quot;&gt;
  
  &lt;kbd class=&quot;icon-shortcut-apple&quot;&gt;cmd+shift+e&lt;/kbd&gt;
  
  
  &lt;kbd class=&quot;icon-shortcut-windowslinux&quot;&gt;ctrl+shift+e&lt;/kbd&gt;
  
&lt;/div&gt;

&lt;p&gt;Same as the above but listing only files that have been edited.&lt;/p&gt;

&lt;h5 id=&quot;tip&quot;&gt;Tip:&lt;/h5&gt;

&lt;p&gt;Start typing to filter the list.&lt;/p&gt;

&lt;h3 id=&quot;navigate-backforward&quot;&gt;Navigate Back/Forward&lt;/h3&gt;

&lt;div class=&quot;shortcuts&quot;&gt;
  
  &lt;kbd class=&quot;icon-shortcut-apple&quot;&gt;cmd+alt+left/right&lt;/kbd&gt;
  
  
  &lt;kbd class=&quot;icon-shortcut-windowslinux&quot;&gt;ctrl+alt+left/right&lt;/kbd&gt;
  
&lt;/div&gt;

&lt;p&gt;To understand this shortcut, think about how the back and forward buttons work in a web browser. Now, instead of thinking in web pages, think about source code! So when you drill down in code or open a new file, the IDE will remember where you where before, allowing you to quickly go back.&lt;/p&gt;

&lt;h3 id=&quot;last-edit-location&quot;&gt;Last Edit Location&lt;/h3&gt;

&lt;div class=&quot;shortcuts&quot;&gt;
  
  &lt;kbd class=&quot;icon-shortcut-apple&quot;&gt;cmd+shift+backspace&lt;/kbd&gt;
  
  
  &lt;kbd class=&quot;icon-shortcut-windowslinux&quot;&gt;ctrl+shift+backspace&lt;/kbd&gt;
  
&lt;/div&gt;

&lt;p&gt;This is a variation on the “Navigate Back” shortcut that cycles between the locations where you typed something.&lt;/p&gt;

&lt;p&gt;Picture yourself fixing a nasty bug. You think you have the solution so you start fixing it but then realize that you have to look at the android source code and a couple other classes in your project. You enter a function, which leads you to another class, which leads you to another thing and 20 steps later, you finally have the insight needed to complete your fix… but in which file and at what line where you again? Just use this shortcut and you are right back at the exact line where you stopped writing.&lt;/p&gt;

&lt;h3 id=&quot;show-usage&quot;&gt;Show Usage&lt;/h3&gt;

&lt;h5 id=&quot;in-a-persistent-panel&quot;&gt;In a Persistent Panel&lt;/h5&gt;

&lt;div class=&quot;shortcuts&quot;&gt;
  
  &lt;kbd class=&quot;icon-shortcut-apple&quot;&gt;alt+f7&lt;/kbd&gt;
  
  
  &lt;kbd class=&quot;icon-shortcut-windowslinux&quot;&gt;alt+f7&lt;/kbd&gt;
  
&lt;/div&gt;

&lt;p&gt;Shows where something is used. For a class member, it will show where reads and writes are made. For a method, it will show where it is called. For a class, it will show where new instances are created.&lt;/p&gt;

&lt;p&gt;You can use the arrow keys and the return key to navigate trough results. You can then press the escape key to go back to the editor.&lt;/p&gt;

&lt;h5 id=&quot;in-place&quot;&gt;In Place&lt;/h5&gt;

&lt;div class=&quot;shortcuts&quot;&gt;
  
  &lt;kbd class=&quot;icon-shortcut-apple&quot;&gt;cmd+alt+f7&lt;/kbd&gt;
  
  
  &lt;kbd class=&quot;icon-shortcut-windowslinux&quot;&gt;ctrl+alt+f7&lt;/kbd&gt;
  
&lt;/div&gt;

&lt;p&gt;Same as before but shows the information in a popup.&lt;/p&gt;

&lt;h3 id=&quot;goto-declarationimplementation-drill-down&quot;&gt;Goto Declaration/Implementation (Drill Down)&lt;/h3&gt;

&lt;p&gt;Here are three shortcuts to drill down into a symbol:&lt;/p&gt;

&lt;h4 id=&quot;goto-declaration&quot;&gt;Goto Declaration&lt;/h4&gt;

&lt;div class=&quot;shortcuts&quot;&gt;
  
  &lt;kbd class=&quot;icon-shortcut-apple&quot;&gt;cmd+b&lt;/kbd&gt;
  
  
  &lt;kbd class=&quot;icon-shortcut-windowslinux&quot;&gt;ctrl+b&lt;/kbd&gt;
  
&lt;/div&gt;

&lt;div class=&quot;shortcuts&quot;&gt;
  
  &lt;kbd class=&quot;icon-shortcut-apple&quot;&gt;cmd+click&lt;/kbd&gt;
  
  
  &lt;kbd class=&quot;icon-shortcut-windowslinux&quot;&gt;ctrl+click&lt;/kbd&gt;
  
&lt;/div&gt;

&lt;p&gt;Goes to the declaration of the class, method or variable. Mostly useful on classes and methods since it redirects to the implementation.&lt;/p&gt;

&lt;h4 id=&quot;goto-implementation&quot;&gt;Goto Implementation&lt;/h4&gt;

&lt;div class=&quot;shortcuts&quot;&gt;
  
  &lt;kbd class=&quot;icon-shortcut-apple&quot;&gt;cmd+alt+b&lt;/kbd&gt;
  
  
  &lt;kbd class=&quot;icon-shortcut-windowslinux&quot;&gt;ctrl+alt+b&lt;/kbd&gt;
  
&lt;/div&gt;

&lt;p&gt;Shows a list of all the classes/interfaces implementing the selected class/interface. Also works on methods to find where they are implemented/overriden. On variables, it has the same effect as &lt;em&gt;Goto Declaration&lt;/em&gt;&lt;/p&gt;

&lt;h4 id=&quot;goto-type-declaration&quot;&gt;Goto Type Declaration&lt;/h4&gt;

&lt;div class=&quot;shortcuts&quot;&gt;
  
  &lt;kbd class=&quot;icon-shortcut-apple&quot;&gt;ctrl+shift+b&lt;/kbd&gt;
  
  
  &lt;kbd class=&quot;icon-shortcut-windowslinux&quot;&gt;ctrl+shift+b&lt;/kbd&gt;
  
&lt;/div&gt;

&lt;p&gt;When the caret is on a variable, it will go to the declaration of its type. For example, if I have the following line:&lt;/p&gt;

&lt;p&gt;&lt;code class=&quot;highlighter-rouge&quot;&gt;Developer phil = new Developer(&quot;Phil&quot;);&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;If the caret is on the variable “phil”, this shortcut will go to the declaration of the “Developer” class.&lt;/p&gt;

&lt;h3 id=&quot;goto-super&quot;&gt;Goto Super&lt;/h3&gt;

&lt;div class=&quot;shortcuts&quot;&gt;
  
  &lt;kbd class=&quot;icon-shortcut-apple&quot;&gt;cmd+u&lt;/kbd&gt;
  
  
  &lt;kbd class=&quot;icon-shortcut-windowslinux&quot;&gt;ctrl+u&lt;/kbd&gt;
  
&lt;/div&gt;

&lt;p&gt;This will open the parent of the current symbol. Pretty much the opposite of &lt;em&gt;Goto Implementation&lt;/em&gt;. If the cursor is in an overriden method, it will open its parent implementation. If the caret is in a class but outside the method or on the class name, it will open the parent class.&lt;/p&gt;

&lt;h2 id=&quot;thats-all-folks&quot;&gt;That’s all folks!&lt;/h2&gt;

&lt;p&gt;In the next article, we’ll take a look at more Navigation shortcuts!&lt;/p&gt;
</description>
        <pubDate>Mon, 14 Oct 2013 15:30:04 -0400</pubDate>
        <link>http://www.developerphil.com/android-studio-tips-tricks-moving-around/</link>
        <guid isPermaLink="true">http://www.developerphil.com/android-studio-tips-tricks-moving-around/</guid>
        
        
      </item>
    
  </channel>
</rss>
