Android Studio notes

Russell Bateman
November 2022
last update:

Years ago, on Eclipse Galileo and Helios, in 2010, I wrote some Android applications. This is me trying to resurrect that knowledge, but using (IntelliJ IDEA).

Any tutorial will start out saying things that aren't possible as long as you don't have the following plug-ins installed and enabled:

  1. Android
  2. Gradle—because Google developers don't like Maven—this is their way to get you off of it
  3. Groovy—even thought I will not use it
  4. Kotlin—even thought I will not use it
  5. Smali Support—don't know what this is
  6. There are others that, as you enable the above, light up because they're needed such as JVM Microservices Frameworks and Design Tools—not to worry.

Links worth listing...

Install Android SDK

Once you're close, you should see this after doing File → New → Project...

Click Android at left:

Then, click on Install SDK, then Next, then Next again, then Next again, then you must Accept the license agreement, then click Finish and wait awhile, then Finish again.

Then, you'll be able to Select a Project Template. This is the point at which you should find yourself rejoining any tutorial you're trying to follow.

The templates are as follows:

  1. Phone and Tablet—this is probably what you were after
  2. Wear OS
  3. Android TV
  4. Automotive

To the right of the Phone and Table template, there are many starter "activities." Knowing the right one to choose will get you a lot further down the road on the application you're planning to write. The default is named "Empty Activity."

Clicking Next will get you a dialog ready to begin your application by choosing where in the filesystem you wish to keep development, by what name, etc. For example, I'm writing an Attendance utility, to aid in counting a few hundred bodies in a crowd.

When you click Create, it will take a while, but then I had a new project entitled, "Attendance," in a new "instance" of IDEA.

This looks similar to stuff I was used to seeing about 12 years ago when I was writing Android phone software, so I think I'm there.

Second beginning tutorial, Using the Android Visual Designer
  1. I note that it's apparently no use to use a JPeG in the first exercise. I found one in Google images, a 3D Droid, but had to convert it to PNG (and I made the background transparent while I was at it).

  2. Adding a text view (or label)...
  3. For the Textview widget, it appears now to be called Plain Textview. Here are the steps to using it:
    1. Drag the Plain Textview to the center (underneath the droid).
    2. Scroll down in Properties to text, but don't type in the value. Instead...
    3. Click in the ellipsis to get a Resources dialog,
    4. click the New Resource button,
    5. choose New String Value..., then...
    6. name this string resource (Resource name:), e.g.: "welcomeText", then
    7. fill in the Resource value: with something like "I'm so cool!".

    This string ends up on the path res/values/strings.xml.

  4. Next, we adjust the look of this new test...
    1. In Properties, expand padding and give all the size "10dp".
    2. For color (for instance), it's possible to introduce a new resource, just as we did for the text, and come up with some funky name like "greenMachine", with value #739C02, then reuse "greenMachine" elsewhere in your work. That way, you only have to change the value in one place to affect all uses.
    3. Similarly, create a resource name for large text that can be used here and there.

  5. I note that the "themes" stuff is very different in my version of the Android SDK designer. Simply put, I couldn't find the Theme control the instructor used to get rid of the application name at the top of the window. So, for example, if I want to get rid of the application name at window's top, I have to go into src/com/example/CoolDroid/MyActivity and add:
    requestWindowFeature( Window.FEATURE_NO_TITLE );
    by hand to the code to make this happen though I will not see this in the designer.

  6. Creating special preview versions aren't done at all the way the version of the designer he was using was shown.

At this point, I note that the formal Android Video Tutorials page has additional, useful stuff to cover:

  1. Events and the Android Coding Experience
  2. Android Unit Testing
  3. Packaging App[lications] for the Store
  4. Using Android SDK Tools from IntelliJ IDEA

And, I'm interested in all of them, though I'm acquainted with the events thing.

However, I'm tired of this and I think I'll move on to my friend, Lars Vogel.

Android Unit Testing

JUnit works, but it can't be used to test Android-specific components for which there are wrappers. I haven't done this tutorial yet.

Using Android SDK Tools from IntelliJ IDEA

I want to make some observations on this.

  1. The list of SDKs I got (File → Project Structure → Platform Settings → SDKs) did not include anything like what the tutorial shows. For now, because I haven't set anything else up, I see only "Android API 23 Platform" (and no Android OS versions).

  2. When I did Tools → Android → AVD Manager, I couldn't see anything happen for the longest time. Ultimately, I discovered that the Android Virtual Device Manager comes up as nearly nothing, but an almost invisible booger in the top-left corner of my desktop, just under the menu bar (I'm running Cinnamon with just a top panel). I had to grab it and throw it open to see the list of virtual devices.

  3. Importantly, the instructor points out, by showing File → Android → Enable ADB Integration, that as long as this is checked, which it is by default, other Android debugging tools (he listed DDMS and Dalvik Monitor Server) cannot be used.

  4. There is no Draw 9-patch.

Android software component parts—at a glance
  1. Application, an Android application can have one Application class instance, instantiated as soon as the applications starts (and the last to stop when shutting down).
  2. Activity, the visual representation of an application; there can be several. Activities are the basis for the user interface.
  3. Context, connects to the Android system executing the application.

Additional notes breaking down Android development...

  1. AndroidManifest.xml, for configuring the application.
  2. Resource files
    • /res/drawables, images or XML files describing Drawable objects.
    • /res/values, definitions of strings, colors, dimensions, etc. via XML. (E.g.: /res/values/strings.xml.) Files that define the appearance of the application.
    • /res/layout,
    • /res/animator, definitions of animations in XML.
    • /res/raw, arbitrary files saved in their raw forms to be accessed via InputStream.
    • /res/menu, definitions of actions that can be used in the application toolbar.

Technology lists...

...toward functionality I know I'll need in an application I'm considering.