Archive for the ‘Android’ Category.

Log all SQL statements in an Android app

If you are using SQLite as your data store in an Android app, and you want to try and trace through the SQL statements that are occurring, it can be painful, especially if you are working with a large code base that you may not be 100% familiar with.

Luckily, there is a super easy way to do this with no code changes. Once you have opened the simulator, go to the terminal and execute these commands:

adb shell setprop log.tag.SQLiteLog V
adb shell setprop log.tag.SQLiteStatements V
adb shell stop
adb shell start

Then, in the Android monitor, you will probably want to filter by SQLiteStatements to see the relevant entries.

View the Android activity stack

Have you ever been developing an Android app, and wanted to find out what activity you were looking at on the screen without spelunking through mountains of source code? Well luckily, there is a quick way to view the Android activity stack.

(Please note that these instructions are for use on a Mac. The corresponding Windows way of doing things is undoubtedly similar.)

If you have ADB installed and running on the command line, then go into Terminal and enter the following command:

adb shell dumpsys activity | grep -i run

Upon doing this, you should see a listing that looks something like this:

mbp:~ user$ adb shell dumpsys activity | grep -i run
    Running activities (most recent first):
        Run #5: ActivityRecord{3d31e5ec u0 com.yourcompany.yourapp/.ui.CustomerDetailActivity t211}
        Run #4: ActivityRecord{18b02af2 u0 com.yourcompany.yourapp/.ui.CustomerListActivity t211}
        Run #3: ActivityRecord{517ab43 u0 com.android.settings/.Settings t180}
        Run #2: ActivityRecord{2e389c3c u0 com.android.chrome/com.google.android.apps.chrome.document.DocumentActivity t179}
        Run #1: ActivityRecord{8583e3d u0 com.google.android.googlequicksearchbox/com.google.android.sidekick.main.optin.NewOptInActivity t153}
        Run #0: ActivityRecord{14e94b15 u0 com.google.android.googlequicksearchbox/com.google.android.apps.gsa.legacyui.VelvetActivity t153}
(more stuff after, not important)

If you look at the top of that list, you will see that the CustomerDetailActivity class is at the top of the activity stack.

Keep in mind that you may need to get ADB set up on your Mac, the easiest way is to install the tools through brew, and here are the Terminal commands necessary to do this:

1. Install homebrew:

ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

2. Install ADB:

brew install android-platform-tools

3. Test ADB:

adb devices

That last command above will just verify that you have a device hooked into your computer. This also appears to work with the Android emulator provided by Android Studio, but if you are using Genymotion, it should work fine with that one as well.

BTW, Happy 50th Birthday to Star Trek, which debuted on American television on this date way back in 1966.

P.S. Credit where credit is due: View activity stack in Android – Stack Overflow and Installing ADB on MAC OS X – Stack Overflow were obviously key.

Writing your first Android App (GDG Columbus meeting, February 21, 2013)

Last night, I attended the Google Developers Group Columbus meeting “Writing your first Android App presentation” at the Blue Diesel offices here in town. Special thanks to Casey Borders, the main presenter who kept us moving through the code heavy presentation. I am still a novice when it comes to Android development, so I did learn quite a bit at the meeting.

BTW, happy birthday to Jeri Ryan, who capably portrayed Seven of Nine in Star Trek Voyager.

The technical term is “Leap Month”

So I am guessing that Google needs some help in their development and/or QA departments. Or else Google knows something that the rest of us don’t know…

I saw this little nugget tweeted about this morning and had to try it for myself. Sure enough, my Galaxy Nexus 7 with Jelly Bean 4.2 is missing the entire month of December. (To reproduce, go into the People app, edit a contact, tap ‘Add another field’, select ‘Events’, and notice that December is not in the month scrolly.)

In an unrelated story, I predict that Android 4.2.1 will be coming out very soon.

BTW, Happy 50th Birthday to Kirk Hammett, lead guitarist for Metallica.

Android Jelly Bean 4.1.1 Easter egg

I just stumbled on this by accident this morning. After my Google I/O provided Nexus 7 had an OTA update, I went into the About tablet section of the Settings app, and somehow I triple tapped on the Android version 4.1.1 table cell, and I got this:

Android Jelly Bean 4.1.1 Easter egg

I have always been a fan of Easter eggs ever since I found out how to find the secret room in Atari 2600 Adventure. BTW, Happy Birthday to Jerry Doyle, who was great as the security chief in Babylon 5.

ADDENDUM: Two things to add, one good and one bad. The good thing is that my buddy John noticed that if you draw around the outer edge of the big bean, you get a screen with a lot of littler beans, which can be flung about. No collisions though. And the bad, it is sad to note the passing of Jon Lord, a giant in world of music.

Google I/O day 1

Well day 1 of Google I/O is in the rear view mirror. While the event logistics were not the best, the content was decent, if a bit geared toward the intermediate to advanced Android developer. The line to get my Android developer devices was far too long, so I decided to wait until the next day.

After the conference was done for the day, I decided to take public transit and head over to Amoeba Music in Haight-Ashbury, and I was a bit diasppointed. I had not been there in many years, and I guess I remember it having more selection before. But I could be wrong.

BTW, happy Perfect Number Day to everyone out there. Yeah, that is not an actual holiday, I just made it up.

I Want My MP3

Please take a look at the two electronic devices in the following picture:

Electronic devices

One of these devices plays the MP3 files that I ripped in iTunes from CDs that I own, and one of these devices does not. (The Joe Satriani pick is included just to give you an idea of the size of the device on the left.)

I think you can see where I am going here with this one. The cheapo flimsy extra-white Kube MP3 player on the left plays the MP3 files just swimmingly. Conversely, this is not exactly what I am expecting to see when I go to the music player on my shiny new Samsung Droid Charge from Verizon:

Android screen shot

Anybody have any ideas? If I reboot the device, the MP3 files play for a while, and then it goes back to the wonderful “Sorry, the player does not support this type of audio file” message. Also, I have no intention of uninstalling the Twitter app. I use the Twitter app and I am not sure if it would even go away if I tried to uninstall it. (I have tried repeatedly to uninstall “Let’s Golf” from the device, but alas each time I uninstall it, it shows back up again.)

If you would like to follow along with this on the Verizon support board, please feel free…

MP3 files will not play

Unfortunately, you would need to sign up for a forum account to contribute. If you have something to add, please feel free to click the Comment link just below this post.

BTW, Happy Pi Approximation Day. July 22, 22 divided by 7 is 3.142857 (decimal pattern then repeats), which is as close to pi as you can get with a fraction made up of a numerator and denominator that are reasonbly small.

Droid tethering with PdaNet

By the way, I forgot to mention that while John and I were on our Codestock trip, I got tired of hoping beyond hope that the 2.2 Froyo update would appear on my Verizon Droid and purchased a license for the PdaNet software for Android. (I have a great fear of open wi-fi access points.)

It worked flawlessly with both the Mac OS X and Windows 7 operating systems on my BootCamp MacBook Pro. Nice job June Fabrics. Here is a link to their Android product:

PdaNet Android tethering

The demo of the software will run for 14 days, and then it will start blocking secure web sites. Also, you install a client application on your Windows or Macintosh computer that you need to run, along with running the PdaNet application on your device and activating the USB or Bluetooth mode. I did not try the Bluetooth mode, I just brought my Droid USB cable and communicated that way.

I highly recommend the software for Droid owners who need an internet connection on their laptop while on the go.

My Tracks Android app review

I saw a news blurb a while back about this new app from the Google folks called My Tracks. I downloaded it to my Droid right away, but really didn’t try it out until today.

So I decided to try and use the application while walking one of my dogs. The navigation around the application is pretty simple, and the track recording seemed to work very well. After I got back from the walk, I was able to see the path that I walked along with a bunch of statistics about it.

The program has upload options to send to Google Docs and Google Maps, so I tried them both at first. This first upload did complete to my Google Docs, but I did have a bit of trouble when it tried to upload the track to Google Maps. The first few times I tried it, I got some miscellaneous errors, such as an authentication error and other nondescript messages. Finally it did go through, and the track then was showing up on the My Maps page of Google Maps.

Even though this app is in the early stages of development, I think it rates quite well. I would give it a 4 star rating, if only because I had some trouble getting the Google Maps upload working.

If you can find it in your heart to help out a fellow nerd, please help out Shawn Powers, he is having a tough go of it. Here are the details:

Urgent: Help Shawn Powers & Family

Oh, and I hope everyone out there had a good Martin Luther King Day.

Two weeks with Droid

So far, I haven’t seen really anything yet from the Droid that is going to cause me to change my 4-and-a-half star rating. Especially after I actually found the question mark key on the slide out keyboard. (It’s just to the right of the L key and just above the period key, where the semicolon key would be on a normal QWERTY or TVQUIZ keyboard.)

On the plus side of the ledger, I traveled with the phone for the first time today, and it worked flawlessly on my drive to visit the folks. The navigation application is so much superior to my trusty old Alpine Blackbird GPS that it isn’t even funny.

I am not at all impressed with the battery life, however. During the week, I don’t think that I am using it excessively, but by the time I get home from work, the freshly charged battery is down to about 30% or 40%. This would seem to indicate to me that I better not try to squeeze two days worth of usage out of it before recharging. The problem here I think is that I would like the wi-fi to be on so that I am not burning through my 5GB unlimited data plan, but it is probably draining the battery quite a bit. More experimentation with the device is called for here.

On the application front, I have only downloaded free apps so far, and there are quite a few good ones. I do like the game Jewels, a Bejeweled clone. I wish I could figure out how to use Google Sky Map, it seems to be so jittery that I can’t get it to behave long enough to try and find anything.

If anyone has any suggestions about how to maximize battery life, please let me know.