Developing Android on Android Automate Your Device with Scripts and Tasks 1st Edition Mike Riley 2024 Scribd Download
Developing Android on Android Automate Your Device with Scripts and Tasks 1st Edition Mike Riley 2024 Scribd Download
https://ebookultra.com
https://ebookultra.com/download/developing-
android-on-android-automate-your-device-with-
scripts-and-tasks-1st-edition-mike-riley/
https://ebookultra.com/download/developing-android-applications-with-
adobe-air-1st-edition-veronique-brossier/
ebookultra.com
https://ebookultra.com/download/automate-everyday-tasks-with-chatgpt-
plus-meap-v03-natassha-selvaraj/
ebookultra.com
https://ebookultra.com/download/android-development-with-kotlin-1st-
ed-edition-moskala/
ebookultra.com
Android Development with Flash 1st Edition Julian Dolce
https://ebookultra.com/download/android-development-with-flash-1st-
edition-julian-dolce/
ebookultra.com
https://ebookultra.com/download/android-forensics-investigation-
analysis-and-mobile-security-for-google-android-1st-edition-andrew-
hoog/
ebookultra.com
https://ebookultra.com/download/unboxing-android-usb-a-hands-on-
approach-with-real-world-examples-1st-ed-edition-regupathy/
ebookultra.com
Developing Android on Android Automate Your Device
with Scripts and Tasks 1st Edition Mike Riley Digital
Instant Download
Author(s): Mike Riley
ISBN(s): 9781937785543, 1937785548
Edition: 1
File Details: PDF, 25.31 MB
Year: 2013
Language: english
V413HAV
V413HAV
Developing Android on Android
Automate Your Device with Scripts and Tasks
Mike Riley
V413HAV
V413HAV
Many of the designations used by manufacturers and sellers to distinguish their products
are claimed as trademarks. Where those designations appear in this book, and The Pragmatic
Programmers, LLC was aware of a trademark claim, the designations have been printed in
initial capital letters or in all capitals. The Pragmatic Starter Kit, The Pragmatic Programmer,
Pragmatic Programming, Pragmatic Bookshelf, PragProg and the linking g device are trade-
marks of The Pragmatic Programmers, LLC.
Every precaution was taken in the preparation of this book. However, the publisher assumes
no responsibility for errors or omissions, or for damages that may result from the use of
information (including program listings) contained herein.
Our Pragmatic courses, workshops, and other products can help you and your team create
better software and have more fun. For more information, as well as the latest Pragmatic
titles, please visit us at http://pragprog.com.
The Android robot is reproduced or modified from work created and shared by Google and
used according to terms described in the Creative Commons 3.0 Attribution License.
V413HAV
This book is dedicated to my three favorite
M’s: Marinette, Marielle, and Mitchell.
V413HAV
Contents
Acknowledgments . . . . . . . . . . . ix
Introduction . . . . . . . . . . . . . xi
Part I — Customize
1. Getting Started . . . . . . . . . . . . 3
1.1 Analyzing Your Mobile Lifestyle 3
1.2 Mobile Personalization 6
1.3 Next Steps 8
Part II — Explore
4. Automating with Tasker . . . . . . . . . . 41
4.1 Introducing Tasker 41
4.2 Talking Clock 43
4.3 Train Station Alarm 53
V413HAV
Contents • vi
V413HAV
Contents • vii
Part IV — Appendixes
A1. Android Programming Tools . . . . . . . . 187
A1.1 Code Editors 187
A1.2 Source Version Control 193
A1.3 Miscellaneous Tools 198
Bibliography . . . . . . . . . . . . 203
Index . . . . . . . . . . . . . . 205
V413HAV
Acknowledgments
This is my second book for Pragmatic Bookshelf, and it has been a pleasure
to once again work with my dedicated and insightful development editor,
Jackie Carter. If you can follow along with the projects without any problem,
you have Jackie to thank. Her editorial skills and professional project man-
agement were crucial in keeping the book flowing smoothly and on schedule.
I would also like to thank all the wonderful technical editors and beta reader
participants who shared valuable feedback, caught typos and other errors,
and generally offered excellent suggestions on improving the quality of the
book. In particular, I would like to thank Mike Bengtson for his awesome
ingenuity, Corey Butler for his progressive technical edge, Ed Burnette for
his pragmatic expertise, John Cairns for his eagle-eye criticality, and Glen
Ferrel for his proofreading expertise and infectious enthusiasm. I also want
to give a big shout-out to Dr. James Withers and Simon Wood (two of the
geniuses behind the awesome SwiftKey Android soft keyboard replacement
program) for their eagle-eye analysis of the book’s content. And a special
thank-you goes to Jan Debiec and Cristina Zamora for their vigilant review
of the material, active participation in the beta, and unending encouragement
for my work. I am so blessed and humbled to be surrounded by such techni-
cally minded people as gifted, kind, and supportive as you.
No amount of thanks can match the sacrifice my family made to give me the
time to devote to another book. I promise to take a break from book writing
for a while so I can make up for lost time with you.
Lastly, a big high-five to publishers Andy Hunt and Dave Thomas for once
again entrusting me to deliver a book worthy of the Pragmatic Bookshelf
imprint. Thank you for giving me such a wonderfully rewarding opportunity
to do so.
The idea for this book was the result of a conversation I had with Pragmatic
Bookshelf publisher Dave Thomas. He had just acquired a Galaxy S3 Android
phone and wanted to know what kind of cool things he could do with it. Since
I have been an Android user since the release of the first commercial Android
phone, the G1, I had a few suggestions on where to start. As he became more
enthusiastic about the broad possibilities of customization and personalization
that the Android platform has to offer, a new book on the subject started to
crystallize.
The objectives of this book are simple. You will learn about how to apply and
codify your mobile automation needs in an Android program. Using both
scripting and native application development approaches, we will build several
programs that not only teach you how to quickly automate your mobile lifestyle
but also give you the skills to extend these programs beyond their tutorial
roots.
Obviously, the platform has matured considerably in that time. It has also
greatly benefited from its open source approach by fostering significantly
faster innovation compared to closed, proprietary operating systems. Take a
look at a first-generation iPhone compared to the iPhone 5. While the hardware
has vastly improved, the primary user interface is nearly identical. Consider
the differences between Android 1.0 running on a G1 phone and Android 4.2
running on a Nexus 4. The differences are striking. The user interface, hard-
ware support, design aesthetics, and everything but the original design prin-
ciples have rapidly evolved for the better. One benefit from this co-evolution
of hardware and software is that you can do things on a modern Android
device that was the stuff of fiction five years ago. To think that on your Android
device you can now do computing on a scale that was the exclusive domain
of desktop PCs for the last thirty years is awe-inspiring.
Let’s also not forget that, like a desktop computer, Android’s home screen
can be highly customized and extended via custom wallpapers, animations,
icons, folder actions, transition animations, and much more. This degree of
personalization allows you to make your Android device fit your aesthetic
values, daily workflow, and communication and notification preferences, not
the other way around. Third-party extensions and widgets also help push the
envelope of what is possible, further contributing to Android’s success and
dominant market position.
Requirements
This is a book about Android, so it should come as no surprise that a must-
have requirement is an Android phone or tablet running Android OS 4.2
(known by its friendly code name Jelly Bean) or newer. The screenshots used
throughout this book were taken on a Galaxy Nexus phone and Nexus 7
tablet.
In addition to the Android phone or tablet, you should have an active account
on the Google Play store, since a good portion of the software used in this
book is exclusively distributed via the Google Play service.
Lastly, while it’s not required, I strongly recommend you obtain a quality
Bluetooth keyboard known to be compatible with the Android OS. I have yet
to use a Bluetooth keyboard that could not be paired with Android, but key-
boards designed specifically with Android in mind are optimal since they often
have special keys associated with functions such as play/pause music, volume
control, toggle between applications, lock the screen, and so on. My current
favorite mobile Bluetooth keyboard is the Logitech Tablet Keyboard for
Win8/RT and Android, shown in the following figure.1 It is a full-size keyboard
and thus larger than other mobile Bluetooth keyboards that have a smaller
footprint or fold in half for greater portability. Plus, Logitech’s full-size key-
board combined with the protective cover doubles as a phone or tablet stand.
1. http://www.logitech.com/en-us/tablet-accessories/android/tablet-keyboard-android-win8-rt
While you are understandably not going to be able to use this keyboard in a
cramped moving vehicle such as a bus or train, it works perfectly fine sitting
on an airplane fold-down seat tray or desk. And since I’m usually bringing
along a backpack during my commutes, the Logitech keyboard adds practi-
cally no additional weight or bulk to the bag. Besides, you will find that the
keyboard is a sanity saver when editing code or documents on the Android
device.
So, that’s it—a phone or tablet, an active Google Play account, and maybe an
Android-compatible Bluetooth keyboard. For folks like me who have been
around since the dawn of the personal computer era, it is simply amazing to
think how far we have come in the past forty years and how much further
we’ll go in the next forty years.
to see how they work, there is no overwhelming reason for average users to
consider jailbreaking and rooting their Android devices.
In the first part of the book, we will look at the variety of options we have to
customize our Android experience. The home screen, lock screen, widgets,
backgrounds, icons, and touch behaviors can all be personalized to your liking.
Unlike some mobile operating systems that enforce a structured, inflexible
design aesthetic, Android offers desktop-like customization in a mobile
package. We will dive into specific examples for home screen renovation. We
will also take a look at extending our Android experience by calling upon a
variety of Android’s hardware capabilities, such as using the headphone jack
to transform our Android applications into better, more convenient, and
information-rich wearable-computing user experiences.
In Part II, we will dip our toe in the automation waters by taking a look at a
very powerful application called Tasker. We will use Tasker to automate sev-
eral personal workflow needs and get introduced to some basic conditional
programming and control flow while we’re at it. We will also delve further into
the programming landscape with the introduction of Scripting Layer for
Android (SL4A). SL4A will allow us to write scripts in Python, Ruby, and
other popular interpreted languages that will execute on Android and give us
access to most of the system-level calls exposed by the Android SDK. We will
conclude the Explore section of the book by actually programming Android
using the native SDK. But instead of using a personal computer loaded with
the Android SDK, emulator, and related development tools, we will write,
compile, test, and deploy these native applications entirely on our Android
phone or tablet.
In Part III of the book, we will apply what we learned in the first two parts by
first creating a custom Android widget entirely on the device—no PC required.
The final set of projects in the book will wrap these scripting and automation
technologies in friendly user interfaces. These projects will show the versatil-
ity and automation opportunities that Android has to offer. The book also
includes appendixes that review a variety of programming tools that run on
the Android platform, as well as offer additional web resources to further your
own project ideas.
By the end of the book, you should be well prepared to continue the journey
on your own to create an Android experience that perfectly complements your
information-interaction lifestyle.
Online Help
Many websites are devoted to the dissemination of Android news, reviews,
hacking, modding, and programming. Check out Appendix 1, Android Pro-
gramming Tools, on page 187, for a list of some of my favorites. It should go
without saying that for Android development, Google’s http://developer.android.com
website offers the official word on Android application development. This isn’t
just a repository of bland technical documentation but a wealth of useful and
well-written articles, tutorials, and tech notes from the folks responsible for
various portions of the operating system. It’s a resource that any serious
Android developer should have permanently bookmarked.
There are a number of footnotes in the book featuring web links to more online
resources. I also encourage you to post specific questions or comments about
the ideas presented in the book at the book’s web forum. Should you happen
to spot an error, feel free to mention it on the book’s website errata page.
You’re also welcome to contact me directly via my mike@mikeriley.com email
address or follow me on Twitter @mriley. I look forward to hearing from you!
With that, we’re ready to take a look at all the things we can customize in a
nonrooted device running the stock Android 4.2 or newer operating system.
Mike Riley
mike@mikeriley.com
November 2013
Customize
V413HAV
CHAPTER 1
Getting Started
Today’s smartphones are amazing devices. They are such powerful and
capable computing devices that they have even replaced traditional desktop
personal computers for some people. And like traditional desktops, one of the
most exciting aspects of the Android platform, especially when compared to
other mobile operating systems, is its ability to be highly customized. This
customization goes beyond just wallpaper and icon replacements. You can
use Android to create custom tasks, scripts, workflows, and behaviors that
can’t be done easily on most other mobile platforms.
In this book we’re going to go beyond simply locating and installing commercial
Android applications that provide generic functionality to fulfill your needs.
But before we can start crafting scripts and applications that do what generic
Android applications cannot, we need to evaluate key features of what an
Android device has to offer. Then we can determine what to look for in the
Google Play market. If we can’t find what we’re looking for, we can build it
ourselves.
In this chapter, we will take a look at some of these key aspects before decking
out your phone or tablet with themes, widgets, and applications that might
not optimally suit your mobile lifestyle needs.
V413HAV
V413HAV report erratum • discuss
Chapter 1. Getting Started •4
If your Android device is a phone, do you use it primarily for voice calls or
texting? If you use an Android tablet, is it used mostly for reading ebooks or
for surfing the Web? Deciding where you spend the most time with your device
will help narrow down what functionality can be enhanced to improve your
efficiency and satisfaction with the Android OS.
Think about how much time you spend with an application. Is it because it
is so helpful that you can’t imagine life without it? Or is it because the
application is so cumbersome and nonintuitive that it sucks up a substantial
amount of time while you’re fighting the interface? Do you find yourself run-
ning the same type of task over and over again?
If you had the chance to re-create your most frequently used applications,
what would you change about them? Do you have special needs that are not
addressed in these apps?
At first, I wrote a simple talking clock app using the Android SDK but found
it to be inflexible when it came to making tweaks to the routines. If I discovered
a bug or came up with an idea to extend the program’s functionality, I had
to wait until I got home to fire up my computer, run Eclipse, spin up an
Android emulator, load the project, make changes to the codebase, go through
a test/debug cycle in the emulator, and then push the compiled .apk file to
my Android phone via the Android Debug Bridge (ADB). All that work for a
few minor tweaks! Needless to say, there had to be a better way. Hence, the
journey I’ll take you through in this book mirrors my own iterations that best
suited my mobile lifestyle needs.
If you’re like me and you live in the post-PC era by deprecating your desktop
or laptop computer for a phone or tablet alternative most of the time, your
mobile lifestyle is all-encompassing. My phone is always by my side during
my waking hours and on my nightstand when I sleep. Likewise, my tablet is
with me during my commutes and anytime I’m driving somewhere where I
will be away from home longer than an hour. Just as noteworthy to-dos pop
into my head while on the go, ideas for enhancements to existing Android
apps I have written have to be captured at that moment before they are lost
into the ether of the day’s demands.
Having the flexibility to make these changes on the fly has been about as
game-changing for me as when I bought my first home computer in the 1980s
(an Atari 400 with its craptaculous membrane keyboard) and then could write
my own apps without having to wait for computer lab time at school. That
freedom and flexibility changed my life back then, and as the Android platform
matures with the ability to develop apps on the device rather than a hulking
piece of hardware, that life-changing experience is resurfacing.
To put yourself in a mobile lifestyle frame of mind, here are some questions
to ponder when considering how you use your Android device for your own
customization opportunities:
• What hours of the day do you use your phone or tablet? If you respond
“All the time,” what are the time ranges that you use the device the most?
• What applications do you spend the most time using? If you’re not sure,
Android’s Data Usage and Running apps (shown in the following figures)
are accessible via the Android Settings application.
Figure 2—An example of Android’s data Figure 3—A list of currently running
usage applications
While not a true reflection of time spent with each application, these two
measurements can help you to a certain degree by showing you which
programs consume the most bandwidth and power. These data collections
can help you become more aware of which applications are frequently
running (whether you’re aware of them doing so in the background or
not).
• What repetitive tasks do you perform with your device that would save
time if you could automate these efforts? For example, I used to make an
effort to turn on my phone every morning, turn on the WiFi radio, launch
my podcast application (I’m currently a fan of the DoggCatcher Podcast
Player1), and wait for the application to download whatever podcasts were
available. When done, I would then turn off the WiFi radio to conserve
battery. If I forgot or ran out of time, I wouldn’t have any new podcasts
to listen to on the way to work. By the way, I no longer do this manual
process since I’ve scripted the entire procedure to kick off thirty minutes
before I wake up. I’ve also created automated tasks to grab the latest news
and weather to read to me after the clock alarm awakens me. We’ll explore
how to write your own scripts and tasks later in the book.
• What dream applications or widgets do you wish you had but haven’t
seen in the Google Play store? Be as specific as possible. Do you want an
application that will wake you up, turn on the lights, and start brewing
a pot of coffee at the same time? After reading this book and another book
I wrote called Programming Your Home [Ril12], also published by Pragmatic
Bookshelf, you will have the knowledge necessary to bring an automation
example like this to fruition.
With these thoughts in mind, let’s take a closer look at some of the more
interesting personal automation ideas we could build upon.
1. https://play.google.com/store/apps/details?id=com.snoggdoggler.android.applications.doggcatcher.v1_0
• Parse SMS alerts for keywords and react accordingly. If you’re a system
administrator, you could parse SMS messages for the phrase “Server
down” and set off a klaxon-style alarm on your phone or tablet.
• Grab RSS news feeds and repackage them for your own personalized news
broadcast. Set your Android device to connect to the Internet at specific
times throughout the day to fetch RSS feeds, parse them, and convert
the text to speech. Then have it read the news stories to you during your
commute to and from work.
• Have your Android phone automatically turn off all radios except mobile
voice calls and set your display to night mode from the time you go to bed
to the time you wake up in the morning. To help you fall asleep, have
your phone play soothing music or sounds of nature (seashore, forest,
meadow, rain shower, and so on) for twenty minutes, giving you enough
time to peacefully fall asleep.
• Take a photo with your phone or tablet and have that image automatically
cropped, filtered, resized, and posted to your online photo album or blog.
Once you have a list of needs in mind, you can start to define what is neces-
sary to bring these ideas to fruition. If someone hasn’t already done the work
for you and posted the results of their efforts online or in the Google Play
store, you have a few more factors to consider before diving in and expending
the time and effort needed to bring your ideas to life.
certainly helps if you have some coding skills and are willing to learn new
things.
There are also times when writing automated tasks or scripts accomplishes
enough of the intended objective that writing a native application is no longer
necessary. This is particularly true if the script or workflow you are creating
is targeted for your specific mobile lifestyle need. But what I have often dis-
covered with my workflows is that as I show my creations to others, they
excitedly ask whether they can have something similar. That’s where this
book comes in. As the classic Chinese proverb says, “Give a man a fish, and
you feed him for a day. Teach a man to fish, and you feed him for a lifetime.”
Let’s go fishing.
In the next chapter, we will dive into our first layer of customization by mod-
ifying the look and feel of the Android home screen. With the help of a handful
of utilities available from the Google Play store, we can transform the default
Android user interface into a whole new experience.
Within the mobile space scenario, Google’s Android has replaced Apple as
the dominant operating system, in part because of the same openness to
customizing the user experience. A variety of home-screen shells, better known
as launchers, are available through the Google Play marketplace that can
swap out default home-screen graphics, icons, and behaviors. And in contrast
to Apple’s iOS platform, Android allows the placement of onscreen mini-
applications known as widgets to alter the stock Android UI. Pushing the
envelope a bit further are what I call floaters. These are Android applications
that run in a resizable desktop-like window that can multitask and hover on
top of the home screen or other full-screen Android programs.
2.1 Launchers
The stock home screen that comes on the standard Google Nexus devices
offers a crisp, clean interface. But if you don’t like how it looks or want to
remove the Google search bar widget that refuses to budge when you try, you
have several alternative approaches to choose from. These replacement home-
screen layout and theme applications, called launchers, are available for
download directly from the Google Play store. As the name implies, launchers
can be used to launch applications. But they can also be used to customize
everything from the look of icons to the transition animations that are dis-
played when moving between screens.
Most of the commercially available launchers offer a free version to play with
that are either ad-banner supported, restricted in features, or constrained to
a certain degree of customization. If customers like what they see, they are
encouraged to reward the launcher’s creator with a paid upgrade that will
remove ads and/or unlock additional features. The nice thing about these
commercial launchers is that they can easily be installed just like any other
program that can be obtained from the Google Play store. Once downloaded
and installed, the replacement launcher will ask for your permission to always
be used as the default launcher. You can also choose to run a launcher once
before making the launcher replacement a global change. At the time of this
writing, the most popular launchers on Google Play are ADWLauncher EX,3
Apex Launcher Pro,4 GO Launcher EX,5 and Nova Launcher Prime.6 Let’s take
a brief look at each of these to see what they have to offer and what differen-
tiates one from the other.
1. http://en.wikipedia.org/wiki/TouchWiz
2. http://en.wikipedia.org/wiki/HTC_Sense
3. https://play.google.com/store/apps/details?id=org.adwfreak.launcher
4. https://play.google.com/store/apps/details?id=com.anddoes.launcher.pro
5. https://play.google.com/store/apps/details?id=com.gau.go.launcherex
6. https://play.google.com/store/apps/details?id=com.teslacoilsw.launcher.prime
ADWLauncher EX
One of the most downloaded launchers on the market, ADWLauncher EX’s
main claim to fame is that it runs on platforms as far back as Android OS
version 1.6. Even on that early Android release, ADWLauncher EX offers the
same kind of eye candy and customization features found on later Android
releases. However, maintaining this visual compatibility comes at the price
of a slightly larger application installation size compared to other launchers.
Pros
• Runs on the Android operating systems as far back as version 1.6 (aka
Donut)
• Fair number of customization options and graphical flourishes, such as
page transitions, icon adjustments, and app organization styles
Cons
Pros
Cons
GO Launcher EX
With more than a million installations since its release into the Play market-
place, GO Launcher EX is by far the most popular on Google Play and has
Pros
• It’s free.
• This is the most popular launcher on the market, with a thriving add-on
and custom theme market (more than 5,000 and counting).
• It runs on Android 2.0 and newer.
Cons
Pros
Cons
• Comparatively expensive
Fortunately, it’s unlikely that the more popular launchers highlighted in this
book would be engaging in such practices since they are used by so many
people; the likelihood is small that security-conscious customers using these
products would be monitoring the application’s network interaction for any
funny business. Yet while companies that create these launchers are seeking
commercial gain through the sale of their application, the more popular a
launcher becomes, the more likely unscrupulous hackers could seek out and
exploit security flaws in the launcher by exploiting unintentional vulnerabilities
in the target launcher application.
The lesson to be learned with this array of launchers is that Google could
step up its game and bake launcher customization within the Android OS.
Not only will this alleviate security concerns (that these third-party launchers
have unfettered access to so many sensitive areas of the phone or tablet), but
it will also help to standardize on theme formats. Instead of being locked into
one vendor’s interpretation of what a launcher theme should consist of, Google
could help set a universal protocol that Android users and independent theme
designers could follow. Until then, we’re stuck with entrusting these third-
party providers with our device’s security.
Launchers can be combined with custom wallpaper images, icons, and screen
transitions to create a new level of personalized artistic expression among a
new generation of mobile connected users. Just as car exteriors were
customized during the mid-1960s through the ’70s by that generation’s youth,
this design trend has been reborn in the mobile generation. Even more levels
of customization can be realized using widgets. Let’s take a closer look at this
standout feature that is part of the Android OS experience.
2.2 Widgets
A major distinction between a desktop computer and a mobile OS such as
Android is the way people interact with information on the display. A desktop
offers considerably more screen real estate (even more so with multiple
monitors) than is typically offered on a mobile display. As such, running
dozens of windowed applications on a mobile device isn’t very practical. Yet
the power of a multitasking OS such as Android allows for many programs
to be running at the same time.
Android has solved this constraint somewhat with the creation of widgets.
Widgets are small graphical applications anchored to the home screen that
can display data in a space as small as a single icon or expand to take over
most of the screen. In this section, we’ll take a look at how to select and use
widgets, as well as sample a few of my favorite Android widgets.
When widgets were introduced in the early days of Android, they were one of
the most defining features of the OS when compared to competing mobile
platforms. Since then, widgets have found their niche as a collection of useful
albeit limited views often for larger host applications.
For example, many media players available for sale on the Google Play store
include widgets of various sizes that distill basic functions such as play/pause
and forward/rewind onto screen areas that span anywhere from one-by-two
to four-by-four tiles. Other widgets offer scrolling news-ticker-style updates
from RSS feeds, server status, and to-do list reminders, among other things.
In addition to the widgets available on the Google Play store, Android ships
with its own collection of widgets to support the variety of Google applications
on the phone.
Discovering the widgets installed on your Android device and adding a widget to
your home screen is easy. To view the widgets installed on your phone on a
standard Android 4.2 launcher configuration, select the Applications group icon
from the lower center of the screen. This will display icons of all the visible pro-
grams on your device. From this screen, select the Widget tab to view the installed
widgets as shown in Figure 5, Android widgets selection screen, on page 15.
Lock-Screen Widgets
While the original intent of the lock screen Figure 5—Android widgets
was to prevent the phone from accidentally selection screen
launching apps or dialing numbers while
jostling in your pocket, lock screens are increasingly important. Mobile devices
have become containers of personal information, and the content should be
protected with the same security applied in the physical world. But as secu-
rity increases, convenience decreases. So, something as simple as checking
your calendar can become a time-consuming dance of unlocking your phone,
scrolling to the calendar icon, launching the program, scrolling to the
appointment, and expanding the view for details.
To select a lock-screen widget, swipe to the left while the lock screen is
enabled. This will display a blank grid with a plus symbol in the center, as
shown in Figure 6, Adding widgets to the lock screen, on page 16. Select the
plus symbol, and a list of widgets that are lock screen–compliant will be dis-
played, as shown in Figure 7, A selection of lock-screen widgets, on page 16.
Scroll through the list to choose the one you want and place it on the lock
screen via the same procedure as placing a regular widget on the home screen.
7. https://play.google.com/store/apps/details?id=net.nurik.roman.dashclock
The other advantage that DashClock offers is a very easy way to hook into
its API so that third-party data sources can be displayed in DashClock’s
container.8 Roman released the DashClock source code under the open source
Apache License 2.0, making it a hit among developers who have rewarded
Roman’s efforts with a thriving number of add-ons. These range from battery
and dialing extensions to word-of-the-day and Facebook message counts.
Of course, with all these extensions, you have to be cautious about the type
of lock-screen enhancements you install. As is the case with something like
the Gmail or Calendar lock-screen widget, DashClock extensions might be
exposing data that you don’t want to display on a pocket billboard. DashClock
also has access to permissions such as contacts, email, and location that can
be polled by it and the extensions it hosts. So, unless you implicitly trust
whatever extension you host within DashClock, be wary of what you install.
My Favorite Widgets
I try to keep my widget count to a minimum
(see the figure here). Too many widgets,
especially those polling for frequent network
updates, can impact performance and battery
life. I also stay away from the widgets with
lots of graphical flourishes and large screen
footprints because I find them distracting and
overstepping their intention of quickly
assessing the data they are trying to convey.
That said, here are some of the widgets I pre-
fer.
• Calendar
8. http://code.google.com/p/dashclock/wiki/API
onto the surface of the moon has endeared me to all things space. Moon
Phase Pro9 created by developer Udell Enterprises keeps me in touch with
my fascination with celestial bodies. In addition to the main program that
displays the monthly phases of the moon along with other interesting
statistics, the program comes bundled with several widgets of various
sizes and levels of detail.
I use this application each time I press the button on my Android headset.
Created by Android developer Christoph Kober, Headset Button Controller
essentially allows you to assign different actions to each type of headset
button press.10 Those actions can span from running scripts and applica-
tions to reassigning behaviors to other button presses. The program
includes a widget that allows you to quickly switch between different
headset button profiles. We will explore in greater detail and make use
of this application in the next chapter.
• Python Interpreter
This is my second favorite widget and one I built myself. Touching this
widget activates a Pomodoro countdown timer. I will tell you more about
9. https://play.google.com/store/apps/details?id=com.daylightmap.moon.pro.android
10. https://play.google.com/store/apps/details?id=com.kober.headsetbutton
Pomodoro timers and walk you through the process of building this widget
in Chapter 7, Tasker Pomodoro Widget, on page 93.
This is my favorite widget and, like the Pomodoro Clock widget, is also
one I built myself. When tapped, the Check Mail widget will check for new
email and speak any new unread messages received. I find that this widget
and the corresponding script it executes is crucial for the hands-free
reporting of new mail messages. We will be building this widget and the
backend script that powers it in Chapter 8, Messaging Projects, on page
115.
Now you should have a pretty good idea of the types of custom application
launchers and widgets that Android has to offer. In the next section, we will
take a look at a special type of Android application that gives your Android
device a retro feel by harkening back to the days of traditional PC-based,
window-driven GUIs.
2.3 Floaters
There is another category of Android applica-
tions that can be displayed on the screen
within a movable window. I call these pro-
grams floaters. Floaters behave just like a
window in a modern desktop computing OS.
Most can be resized, minimized, and maxi-
mized, and some even support multiple
instances, allowing multiple windows on the
screen at the same time. See the figure here.
That said, there are a few benefits. Let’s say you’re watching a video and need
to check and respond to email. Normally you would have to pause the playback
to do so. Using a floater media player, you can just resize the window while
perusing your messages and then expand the playback to full screen without
missing a moment of content. There’s also the coolness and geek credibility
factors to be able to show colleagues something they might not have thought
possible on a mobile device. Lastly, floaters work rather nicely on a 10-inch
Android tablet thanks to the much larger screen size that gives you the ability
to effortlessly move and resize windows. I tend to use floaters most frequently
on these types of large-screen devices.
While quite a few floater-style applications are available in the Google Play
store, here are a few worthy of a closer look:
• AirCalc11
AirCalc is a simple yet free calculator for Android. It also provides a nice
introduction to floaters and is a great way to determine whether your
Android device supports the app screen overlay techniques employed by
most floater programs. AirCalc can be resized, minimized, and maximized
just as you would expect a traditional windowed application to behave.
• AirTerm12
11. https://play.google.com/store/apps/details?id=com.myboyfriendisageek.aircalc
12. https://play.google.com/store/apps/details?id=com.myboyfriendisageek.airterm
13. http://kevinboone.net/kbox.html
14. http://www.busybox.net
• DICE Player15
• Overskreen16
• Stick it!17
Stick it! is another Android media player that, like DICE Player, provides
video playback within a pop-up window. However, unlike DICE Player,
Stick it! offers a neat feature on higher-end Android devices called Multi-
View. This essentially allows for multiple windows to play back different
video content at the same time. It’s an awesome technology demo, but I
honestly haven’t used MultiView in many real-world scenarios. And as
you can imagine, playing several videos at the same time can be rather
taxing on your battery and system resources. But for a whiz-bang Android
showcase program, Stick it! is hard to beat.
Now that we have all the visual customization tools and applications that we
need to have Android’s home screen look and behave the way we want, let’s
apply these ideas to re-create two home screens. One will emulate a competing
15. https://play.google.com/store/apps/details?id=com.inisoft.mediaplayer.a
16. https://play.google.com/store/apps/details?id=com.myboyfriendisageek.airbrowser
17. https://play.google.com/store/apps/details?id=com.myboyfriendisageek.stickit
phone operating system, and another will re-create the look and feel of a
popular desktop operating system.
18. https://play.google.com/store/apps/details?id=com.gau.go.launcherex.theme.wpsevenstyle
With a backup made, select the Import label from the Backup and Import
screen. Nova Launcher Prime will remind you that your existing launcher
settings will be replaced by the theme being imported. You know, the one you
were supposed to make a backup of, right? Since you do have a backup of
your current configuration, return to the Nova Settings screen and select the
Look and Feel option. From there, choose the Icon Theme option. The list of
the various themes installed on your Android device will be displayed, as
shown in Figure 11, A selection of installed icon themes.
Now we’re going to use Nova Launcher Prime’s ability to import icons from
other launcher application themes. In this case, we will borrow some Windows
Phone–like icons from a Windows 7 GO Launcher theme. Choose the GO
Launcher EX Windows Phone 7 theme from the list. This will replace icons
for standard Android programs such as Browser, Email, and Settings with a
Windows Phone icon lookalike. Arrange your choice of applications on your
home screen accordingly. Press and hold on the home-screen background to
either change it to a solid color or incorporate a matching Android wallpaper.
I prefer the live wallpaper that is installed with the Moon Phase Pro program.
Tinker with the layout until you achieve the look and feel you’re comfortable
with. When you’re done, it may look similar to the one shown in Figure 12,
A Windows Phone theme.
Next, replace the home screen’s background wallpaper with a Mac desktop
wallpaper. Launch the default Android or Google Chrome browser, search
Google Images for “Mac desktop wallpaper,”20 and select any of the ones that
appeal to you. Set the image to your wallpaper by long-pressing the image of
choice. A pop-up menu will appear, as shown in Figure 13, Setting background
wallpaper using an image from the Web, on page 25.
Select the “Set as wallpaper” option. This will download the selected image,
save it locally to your Android file storage, and set the image as the default
home-screen background.
19. https://play.google.com/store/apps/details?id=akglo.themes.macos
20. https://images.google.com
V413HAV
Now that you have the knowledge and the tools to customize your Android
device the way you see fit, explore the numerous themes available for down-
load. If you’re using TeslaCoil’s Nova Launcher Prime, you will find that most
background and icon themes are compatible. However, most graphical
embellishment behaviors that accompany these themes, especially those
written for Go Launcher, don’t work as expected, if at all. Still, there are
hundreds of freely available themes to choose from, and that number is
expanding every day. If you don’t find one you like, you can create your own
by converting pictures you took with your Android’s camera into home-screen
backgrounds and icons. Your first attempts might not be works of art, but
they will most definitely express what you want your mobile computing
experience to look like!
In the next chapter, we will explore how to customize the other side of the
user experience by focusing on audio. Specifically, we will learn how to
leverage audio in Android to augment and in some cases even replace the
Android user interface. Get ready to listen up!
For example, did you know that your Android can speak to you? Ever since
the Android 1.6 OS release, Android has had built-in text-to-speech (TTS)
functionality that could convert text into spoken words. However, it wasn’t
until the release of Android 4.2 that this TTS technology was actually tolerable
to listen to for long stretches. Earlier releases were robotic and lifeless. The
4.2 release includes a far more natural and less obnoxious voice. And if this
default voice isn’t to your liking, third-party text-to-speech synthesis products
like those from SVOX offer a selection of more than forty voices in multiple
languages.1 Before 4.2 came along, I used SVOX for my TTS needs.
But before we get to hear our phone, we should optimize our listening envi-
ronment for on-the-go audio data consumption.
1. https://play.google.com/store/apps/details?id=com.svox.classic
without ever having to remove the phone from its case. Email, text messages,
meeting notifications, countdown timers, motivational reminders, and other
information are controlled and delivered via my audio headset.
This chapter will show you how to put the pieces into place to allow you to
do the same thing. The setup is simple and inexpensive. And unlike Google’s
much hyped and considerably more expensive Glass project, my Android
wearable configuration doesn’t obstruct or distract my vision in any way.
Many people prefer to put their smartphones in their pocket, but I find it far
easier to use a wired headset when the device is holstered in a case strapped
to my belt. I prefer the Case Logic TBC-412 model. Even though this product
is officially designated as a video camera case, I find that it snuggly fits my
Galaxy Nexus even with the added thickness of a 3850mAh extra-capacity
battery. It also protects the phone from the elements, whether that is a drizzle
of rain or a dusty biking trail. The price is also cheaper than custom-designed
slip cases made specifically for the phone.
With the phone safely enclosed, run a headphone wire from your shoulders
to the phone. You can run the wire between layers of clothing to keep it out
of the way. Some headsets come with a helpful plastic clip that allows you to
put some slack into the wire. That keeps the earphones from tugging at your
ears. I attach this clip to my shirt collar to keep the left and right earphone
wires from slipping as I walk. The headphones I use on a daily basis are a
cheap single-button design with a built-in mic that is compatible with most
Samsung Galaxy phone models. These can often be found on Amazon for as
low as a dollar plus shipping. Note that the headset you use must have a
headset button, since you will use that button to answer calls, start and stop
audio, and run applications.
You can opt for a more expensive headset or earphones tailored to your phone
hardware. You can also choose to go entirely wireless via a Bluetooth headset.
But I have found from years of using my wearable configuration that these
choices produce annoyances. For expensive wired headsets, I find that the
wire at the stem of the headphone jack becomes weak over time and eventu-
ally loses either the left or right ear connection. I have even tried shielding
the wire from this wear and tear by looping the wire at the stem of the head-
phone jack and tightly wrapping it with electrical tape to no avail.
As for Bluetooth headsets, I find that the sound quality still hasn’t quite
matched the frequency ranges offered by wired headsets. There is also the
hassle of having to recharge the Bluetooth headset’s battery before use. And
it can be a pain when that charge dies midway through the day without
having the means to recharge it until you’re home.
If you choose a wired approach, you need to manage the path of the wires
from your ears to your encased Android. Depending on the type of activity,
you can try running the wire in between your outer and undershirts, either
in front or back of you. Gadget-friendly clothing from progressive fashion
designers like ScottEVest includes shirts and jackets with dedicated enclosures
to run headphone wiring through so as not to flop around and get in your
way.2
With the headphones in place and the headphone button in a location that
is easy access, you can use this button to control the basic features of the
phone. Answer an incoming phone call as well as pause and play music with
a single short press of the center headphone button. The basic button press
behaviors are more or less universal across all Android phones that support
headset controls.
With your Android by your side and your audio headset on, let’s next turn
our focus to the software involved in voice recognition and spoken text inter-
action.
The default preferred speech engine in Android 4.2 is Google’s own TTS
technology. If you have SVOX or another third-party engine installed, it will
also be listed on this settings page. From this screen, you can also modify
the rate of speech playback, ranging from very slow to very fast. I prefer the
default normal speed, but try each setting to see which of the five playback
speeds works best for you. Select the “Listen to an example” option to hear
2. http://www.scottevest.com
Android speak at the playback speed you chose. And now that we know
Android can talk, let’s explore how we can talk back to Android.
• “Set an alarm for <time>” will set an alarm to sound at the requested
time.
• “Remind me to <task> at <time>” will convert your speech to text and add
the converted statement to your default calendar at the designated time
on the current day.
So, that’s pretty cool, but Google Now has two notable drawbacks. First, while
Google’s voice recognition and speech-to-text translation services are amazing,
3. http://www.google.com/landing/now/
they’re far from perfect. Try any of these phrases on a noisy bus or outside
on a windy day, and you’re not likely to see the results you expected.
You would think that’s because Google needs its server farm to chew through
your speech input, convert it to a text string, and figure out the meaning of
the submitted phrase. But that doesn’t explain why Google offers offline
speech-to-text translation in Android 4.2 and newer. Until Google creates an
API that allows developers to access this offline speech-to-text translation
service, developers need to continue submitting spoken phrases over the
Internet to Google’s servers.
The takeaway from all this is that if you live and commute in a well-connected
city where wireless Internet connectivity is trustworthy, fast, and ubiquitous
and you’re not concerned about the voiceprint data Google is collecting from
your audible queries, then Google Now can be mighty helpful at times. But
while Google Now does a good job of translating responses such as the time
and reminders into audio, most answers require looking at the screen to
review the replies.
When I’m on the go, whether walking crowded city streets to work or riding
my recumbent along winding bike trails, I really don’t want to pull my phone
out of my pocket to see who sent me a text message and what they said, view
any upcoming events on my calendar, or simply check the time.
4. https://play.google.com/store/apps/details?id=mahmed.net.spokencallername
Yale University, distinguished alumni of, 13-19; rigid discipline at, 24;
eminent professors in, 20-28; sectional antagonism in, 25-26;
theological atmosphere of, 13
Young, John Russell, succeeds Gay as managing editor of Tribune, 163;
adopts suggestion to establish Tribune office in London, 220-221
*** END OF THE PROJECT GUTENBERG EBOOK ANGLO-AMERICAN
MEMORIES ***
Updated editions will replace the previous one—the old editions will
be renamed.
1.D. The copyright laws of the place where you are located also
govern what you can do with this work. Copyright laws in most
countries are in a constant state of change. If you are outside the
United States, check the laws of your country in addition to the
terms of this agreement before downloading, copying, displaying,
performing, distributing or creating derivative works based on this
work or any other Project Gutenberg™ work. The Foundation makes
no representations concerning the copyright status of any work in
any country other than the United States.
1.E.6. You may convert to and distribute this work in any binary,
compressed, marked up, nonproprietary or proprietary form,
including any word processing or hypertext form. However, if you
provide access to or distribute copies of a Project Gutenberg™ work
in a format other than “Plain Vanilla ASCII” or other format used in
the official version posted on the official Project Gutenberg™ website
(www.gutenberg.org), you must, at no additional cost, fee or
expense to the user, provide a copy, a means of exporting a copy, or
a means of obtaining a copy upon request, of the work in its original
“Plain Vanilla ASCII” or other form. Any alternate format must
include the full Project Gutenberg™ License as specified in
paragraph 1.E.1.
• You pay a royalty fee of 20% of the gross profits you derive
from the use of Project Gutenberg™ works calculated using the
method you already use to calculate your applicable taxes. The
fee is owed to the owner of the Project Gutenberg™ trademark,
but he has agreed to donate royalties under this paragraph to
the Project Gutenberg Literary Archive Foundation. Royalty
payments must be paid within 60 days following each date on
which you prepare (or are legally required to prepare) your
periodic tax returns. Royalty payments should be clearly marked
as such and sent to the Project Gutenberg Literary Archive
Foundation at the address specified in Section 4, “Information
about donations to the Project Gutenberg Literary Archive
Foundation.”
• You comply with all other terms of this agreement for free
distribution of Project Gutenberg™ works.
1.F.
1.F.4. Except for the limited right of replacement or refund set forth
in paragraph 1.F.3, this work is provided to you ‘AS-IS’, WITH NO
OTHER WARRANTIES OF ANY KIND, EXPRESS OR IMPLIED,
INCLUDING BUT NOT LIMITED TO WARRANTIES OF
MERCHANTABILITY OR FITNESS FOR ANY PURPOSE.
Please check the Project Gutenberg web pages for current donation
methods and addresses. Donations are accepted in a number of
other ways including checks, online payments and credit card
donations. To donate, please visit: www.gutenberg.org/donate.
Most people start at our website which has the main PG search
facility: www.gutenberg.org.