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:
Android
Gradle—because Google developers don't like Maven—this is
their way to get you off of it
Groovy—even thought I will not use it
Kotlin—even thought I will not use it
Smali Support—don't know what this is
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:
Phone and Tablet —this is probably what you were after
Wear OS
Android TV
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
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).
Adding a text view (or label)...
For the Textview widget, it appears now to be called Plain Textview . Here
are the steps to using it:
Drag the Plain Textview to the center (underneath the droid).
Scroll down in Properties to text , but don't type in the value.
Instead...
Click in the ellipsis to get a Resources dialog,
click the New Resource button,
choose New String Value... , then...
name this string resource (Resource name: ), e.g.: "welcomeText", then
fill in the Resource value: with something like "I'm so cool!".
This string ends up on the path res/values/strings.xml .
Next, we adjust the look of this new test...
In Properties , expand padding and give all the size "10dp".
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.
Similarly, create a resource name for large text that can be used here and there.
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.
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:
Events and the Android Coding Experience
Android Unit Testing
Packaging App [lications] for the Store
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.
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).
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.
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.
There is no Draw 9-patch .
Android software component parts—at a glance
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).
Activity , the visual representation of an application; there can be
several. Activities are the basis for the user interface.
Context , connects to the Android system executing the application.
Additional notes breaking down Android development...
AndroidManifest.xml , for configuring the application.
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.