Advancing Backwards

Boldly going in the wrong direction since 2008

Browsing Posts in Mobile Programming

So, its been quite some time since I’ve posted anything here, so its time to break the silence. And, what better way to do so than by posting a small snippet of Android code that tripped me up? Todays topic: Accessing and setting Android system services outside of an activity. This is a small thing that many may already know, but in my tradition of documenting small things that trip me up, Im going to write about it anyways.

continue reading…

So, after a rather long absence from Android, I decided to dive back in and start tweaking an app I started a while back. This particular app uses the GPS to store a location in a database. The problem was, the app would sometimes try and store the location before the GPS was even ready, resulting in coordinates of 0, 0. At the same time, I also wanted the GPS reading to be as accurate as possible before it was stored in the database. Accuracy of +/- 80 feet is not so useful in the long run.

After some thought on how best to accomplish this without pissing off the user (nobody likes an application that seems to hang, even if there is something ticking in the background), I settled on displaying a ProgressDialog to let the user that something is indeed happening, and they can continue once its done.

continue reading…

One thing I’ve been grappling with recently is how to get home screen applications widgets to work for my application. There is a decent tutorial in the Android developer documents about the subject (located here), but it doesn’t really go into too much detail on how to make your widgets interactive. Sure, it shows you how to set up an OnClickListener on an element of your widget to load an activity from elsewhere, but what if you want the widget to do something more, like redraw itself with a new image when its clicked? This seems pretty simple, but to be honest, it took me a lot of fiddling to get it to happen.

continue reading…