May 102015
 

For a recent project, I had to create a game-style controller Android app that senses the phone’s tilt and uses it as an input.

http://i.stack.imgur.com/ylWJb.png (image via SO)

To simplify the explanation, imagine a jet thruster game where the farther you tilt the phone back, the stronger the jet thrusters fire:

  • When the phone sits upright, the thrusters don’t fire at all
  • When the phone is tilted all the way back, the thrusters fire at full force

Going into it, I knew I would need to use Sensors, specifically something about the Accelerometer. Digging in a bit more, no amount of Googling/Stack searching provided me with exactly what I was looking for, so I figured I’d write it up here…

Initial search results:

Solution

My fully open-sourced solution lives here: https://github.com/loisaidasam/tilt

Specifically, check out MainActivity.java:

A few notes:

Jan 132015
 

Big fan of Retrofit, but have a staging server that has an invalid SSL cert?

Fear not! Just use the AllCertsValidClient!

https://gist.github.com/loisaidasam/d4caf3659c8fa7a38222

Example usage:

Gson gson = new GsonBuilder()
    .setFieldNamingPolicy(FieldNamingPolicy.LOWER_CASE_WITH_UNDERSCORES)
    .create();
AllCertsValidClient client = new AllCertsValidClient();
RestAdapter restAdapter = new RestAdapter.Builder()
    .setEndpoint(host)
    .setConverter(new GsonConverter(gson))
    .setClient(client)
    .build();
service = restAdapter.create(MyApiService.class);

Have fun, and be safe! (don’t use this thing in production environments!)

Mar 282012
 
Android Robot. Français : le logo d'android 日本...

Android Robot. (Photo credit: Wikipedia)

Yeah, I know that I’ve been gone for a while, and no, this post won’t have anything to do with music, except to tell you that if you’re in Ljubljana tonight and missing Nils Frahm at Menza pri Koritu then I don’t know what to tell you.

No, today’s post is about finishing and what that means. I was going to start with a dictionary definition, but I think you all know what “finish” means. It means bringing a task or activity to an end; completing something that you started.

In truth, I don’t finish many of the things I start. When I was a kid I quit hockey. In middle school, The Boy Scouts. In high school I quit the swim team after one year. I started a company in college that we disbanded a few years later – in that time (Facebook‘s early days, when there was still space there) we built an entire social network that we never launched to more than a few hundred people. I remember when Facebook first opened their platform, and some of the proofs of concept Facebook apps that I came up with. I was also there with a handful of ideas and prototypes when Foursquare launched their API. Several years ago now, I wrote an entire autonomous Twitter bot platform that I’ve never officially done anything with. Before I moved to Slovenia I spent a few months screwing around with an Arduino, never to actually build anything long-standing or useful. In the last year and a half, I wrote the meat of a brilliant and complex social/gaming web application, working with an excellent UX person who is plugged into New York City’s thriving tech scene (she has friends at TechCrunch, in several influential tech startups, etc.), yet we still haven’t brought it across the finish line. When Android first came out I switched to TMobile and bought the G1. I was at all of the NYC Android meetups. In the last few years, I’ve written seven or eight interesting Android apps that are in a half-finished state sitting in my Eclipse workspace and/or on only my phone. I have all the excuses in the world (hockey got rough, boy scouts got boring, swimming wasn’t fun, no time, lost interest, etc.), but when all is said and done, what it boils down to is that I don’t finish things.

As a side note to any employers who think that they hired/are hiring/will hire a dud, I’m speaking strictly about things that I do/build in my free time; when it comes to a job and being professional, yes I do finish all of the tasks required of me. It is in my code of ethics to uphold my contractual obligations.

But why don’t I uphold that same code of ethics for things that I don’t get paid for? Why don’t I finish things?

I think that the answer lies in the fact that I love making a good proof of concept. I love mock ups. I love the kind of instant gratification that a prototype offers. I love spending enough time with a technology to learn about how it works, grasp it, and build something with it. Maybe my quest for knowledge is breadth-first? Back when I was a junior dev in my first startup, our chief architect (also a good friend) used to compare me and my colleague, saying that I’m like a sponge, soaking up all of the knowledge that I can about everything that I work on, while my colleague strived to finish each assignment as quickly as possible without needing to know why things worked, just that they did. I guess it’s good to have both types on your team. The yin and the yang.

Fast-forward to yesterday in the office: I was about to show off an Android app that I built this past weekend to a few coworkers, when my friend Drazen asked if it was the same app that I showed a few weeks before. I replied that it was something new that I cooked up from my bed this past Sunday morning. Drazen laughed and (rightfully) pointed out the fact that I don’t finish anything. At the time I was like “yeah, yeah” and shook it off, but his words stuck in my head for the remainder of the day. Last night at around midnight I fired up Eclipse, determined to finish what I started. At around 02:30 I had a fully working implementation of my gag app with basic functionality. I quickly read the release docs for the Android Market (now “Google Play”), registered for a developer account, paid the $25, signed my .apk file, posted a couple of shitty screen grabs and descriptions, and by 03:30 I officially had a finished product sitting on the Android Market, available to the masses!

I now present to you, Talking James! A proof of concept of finishing.

QR code for Talking James on the Android Market

QR code for "Talking James" on the Android Market

 

Enhanced by Zemanta