Music

One would hope that playing/managing music on an Android device would be easy, but it’s broken. Here’s why…

I have a lovely HTC One (M8). For those that don’t know, it has forward facing speakers and can play music really loud. I’ve found that it’s now the main way that I listen to music. It also features a micro SD card. When I got it I copied my music collection to the card so I could listen to anything anywhere. But then I started to discover failings; artificial barriers put in place by Amazon and Google.

Amazon

I usually buy my music from Amazon. With my previous phone I didn’t much care where it stored the music. It only had internal phone storage. With this phone I want to keep all of my music together on the SD Card. Well, you can’t to that. The Amazon app will only store music to the phone memory. It’s also stored in protected folders, so moving it isn’t an option.

You can though download the music on you laptop and then move it to the SD Card. Amazon used to limit downloads to track at a time on the (Linux) desktop. They seem to have recently increased this to 24 tracks at a time, but that didn’t seem to work. Must recently I found that I had to download each track to the Downloads folder then create folders/move files in my Music folder. Good work Amazon!

(A warning about the Amazon MP3 Android app; it chews up loads of mobile data even if you don’t use it. Last month it was around 50Mb, which pushed me over my monthly allowance. I’ve disabled the app now.)

Google Play Music

So yesterday I thought I’d try buying music from Google’s Play Music store. I’d noted that the Play app does allow you to set the SD card as the storage device. However, much to my annoyance I found that it’s not stored in the Music folder. It’s stashed away in a folder that Google’s app can access but others can’t. Not only that, the tracks are stored in a flat folder with numeric names. Thanks Google, that’s pretty mean spirited of you.

Now, I could just use the Play Music app to play my music but it niggles me. It insists on opening to the Instant Mix screen and, I imagine, it probably reports everything that I listen to back to Google. (I don’t mind sharing data with Google, but even I have limits.)

As with music purchased from Amazon, I can download the music from Google to my laptop. This does work quite well under Linux, there’s a program that does a proper job of downloading to my Music folder.

So I’ve now downloaded recent purchases to my laptop and copied them to the micro SD card. I’ve also deleted the Amazon downloads from the internal phone storage and deleted the Google downloads from the secret “Google only” folder. The result is that I can now use HTC’s music player for everything.

 

 

Flattr this!

Android Preferences
(and Library Projects)

I’ve been battling with preferences in Android, on and off, since November 2013.

I wrote an app, Pit Board, and at the time split the preferences into two dialog boxes. A simple one for the message text and colour and an more complex one for animation styles and timings. I just created these in dialogs and thought nothing of it.

The animation styles I stored the style as an integer and the animation speed as a long value. I can then use ‘switch’ for the animation style and directly use the long value for the animation. Android preferences allow the storage of these types of variable.

With further development/reading I then wanted to replace my dialog box with a standard PreferenceFragment, which should reduce the work that I do as it automatically stores the values. A change listener can then be used in the activity.

BUT! The standard preference classes don’t have anything for an integer backed list or a way to store long values. Not only that, when setting default values in XML there is no support for long values. As a result I have had to write classes to handle those, and the long values one is a kludge as it stores the defaults as integers.

Library Projects

Obviously, having taken the time to write these I want to be able to share them across apps. At first I tried to put them in a different package (a parent to those that I was for my apps) but this causes problems when compiling. Lots of errors about not finding resources (the R class).

Reading more it seems that projects can be defined as libraries and these can be incorporated at compile time. I set about moving the preferences (and another useful class) to “utils” this morning on the train. Poor internet access can be very frustrating! I studied the examples in the TicTacToe app, but got nowhere. When I tried to compile the project it failed to find the classes that I’d moved to the utility library.

I worked on it on the way home and made the same amount of progress. Once home I googled further and found a useful post which held the secret line that fixed it!

I’d already updated the project, but I hadn’t included the “--library relative/path/to/library/project” bit. When I look at the files I can’t just see what it altered, but it compiles now. (I’d already added the library reference to project.properties and even fixed the capitalisation!)

Flattr this!

Handy Layouts

When developing Android applications the interface layout is usually defined in XML files. Commonly the file main.xml is the definition for the first interface that the application presents to the user.

Android also allows for different layouts to be defined in XML files in different folders. The names of the folders define when the layout should be used. So, for instance, the layout-land folder holds the layouts for the application when running on a device in landscape mode. This method allows design and function to be neatly separated.

It occurred to me on the train this evening, whilst working on an app, that it might be handy to have folders for left and right handedness. This would allow for asymmetric designs, especially in portrait mode, where the device – typically a phone – is being held in one hand. So if an application has multiple buttons on the display for instance, then the more important buttons could be sized/positioned to make them easier to reach.

I don’t know if this already exists, but I wanted to get it out there so that there is prior art, hopefully preventing the likes of Apple, Microsoft and RIM from claiming it as a novel invention and patenting it.

Flattr this!

Android Timer Fault

Android Jelly Bean suffers a weird problem when setting a timer that is not on a ten minute interval.

I first noticed it when setting a timer for frozen pizza. They take 12 minutes, but I found that the alarm didn’t sound until much later. With some experimentation it seems that asking for a timer to be set over 10 minutes, but not at a ten minute interval, breaks things. It adds 90 minutes to the time.

Timer fault on Android
Illustration of Android timer fault

In this example I said “set a timer for 12 minutes”. As you can see from the time in the top right corner it was just after 10pm. The timer should have been set for 10.14pm but has been set for 11.44pm. If a request is made to “set a timer for 20 minutes” it seems to work.

I see this fault on both my phone (HTC One S running 4.1.1) and my Nexus 7 (4.2.2).

This issue seems to be fixed by recent updates.

Flattr this!

Android Testing

The Art of Agile Development, by James Shore and Shane Warden is an excellent book. I recently read it and found it inspiring. Whilst many of the practices don’t work for a lone developer, test driven development seems like it will.

So now I’m trying to set up unit testing for when I’m developing Android appications. However, I found the guidance on the Android developer website unclear. Having spent some time getting frustrated at my apparent inability to follow simple instructions I made it past the first step. I share that first step in the hope that I can help others.

The developer notes give examples using relative paths. I found that this didn’t work. Here is the relevant folder structure for my application, which is called Aoide.

~\
  Android\
          aoide\
                AndroidManifest.xml
                build.properties
                build.xml
                default.properties
                local.properties
                proguard.cfg
                bin\
                gen\
                libs\
                res\
                src\

The Testing Fundamentals page shows that I want to create a tests folder in the aoide folder. I found this command, run from the Android directory, worked for me:

tools/android create test-project -m ~/Android/aoide \
    -n AoideTest -p ~/Android/aoide/tests

Now to figure unit tests…

Flattr this!

Gingerbread [part 2]

A follow up to my last past.

Don’t Bother!

If you have an HTC Desire and you’re considering installing the developer update then don’t bother. HTC still include lots of crap that you don’t want and hide/replace the Google goodness that you do want.

I have been asked about battery life. It might be a little better, I have no hard figures, but after a few weeks of general use I have to say that I am underwhelmed. WiFi notification is annoying, but probably a result of improvements to aid power conservation. I got to the point where I tried to root the phone so I could clear stuff off it. I can’t do this now as the software is too new.

I have also noticed that synchronisation fails when storage falls below the threshold; 15MB on the Desire. Is this and Gingerbread feature?

Apps

It would also be really good is developers made their applications installable to the SD card. None of the Twitter clients that I’ve tried (Tweetdeck, Seesmic, Twitter) will do this. Google+ won’t either, and at 8MB it’s pretty big. I know that there are limiting factors. Applications that run as a service, for example, must be installed on the phone. But I also believe that this is easy to work around, perhaps by spliting the application into two parts. (The Ebay application provides notifications but can be moved to the SD card.)

Flattr this!

Gingerbread

Upgraded my HTC Desire to Gingerbread today.

The upgrade was promised some time ago but then HTC said that there wasn’t enough memory. There was outcry and, after removing some of the Sense UI stuff they freed enough space. However, the update is “only intended for developers”. I read one blog saying that there might be issues with SMS and MMS messages. I did wonder if, post update, I had a Wi-Fi issue, but it seems okay after a power cycle.

The Update Process

This was annoying. I downloaded the zip file and unpacked it only to find that I needed a Windows PC. I run Fedora on both my desktop and my laptop. I borrowed my daughter’s laptop. Next, I had to install HTC Sync. This required Adobe AIR and three other components. (All were included in the HTC install file, no wonder it’s 55MB!) The update did run smoothly and quickly once it started. There were plenty of warnings too. Rightly so; all operator content, messages, contacts, settings got wiped. Like it says, backup before installing!

Benefits

Not many!

If I’d known how little difference it would make I wouldn’t have bothered. I wanted the pretty new keyboard and more space. I’ve got a little more space, but the keyboard is still HTCs version and there are still many HTC applications that I don’t want and can’t delete. The Stocks tracker – not interested. And why does the HTC mail application take 3.95MB. I don’t use it, I use GMail and that takes 1.47MB. Are they the same?

The way that Wi-Fi works seems slightly more annoying. It tells me that a network is available, long enough for me to wonder if it will connect. It does connect, most of the time, I think. Perhaps the signal threshold has been changed.

Update: I’ve come to the conclusion that if the signal is weak then no attempt is made to connect, just notification given that a wireless network has been detected.

Power management is another improvement, but I’ll have to see how it goes for a while before I can tell if that is improved.

Flattr this!