Friday, May 10, 2013

Utah Teapot on Android

I am TOTALLY impressed with this code I found: It is the Utah Teapot that you can tilt it around with the accelerometer.

OpenGL is tricky. There are so many things to set up and do one thing wrong you get black screen. This Utah Teapot is classic data set for computer graphics. Just thinking about parsing the data already gives me a headache...

* * *
I want to do something that sounds simple... set a camera at (10,10,10), looking at the origin... so I can plot a R2->R graph like z=x2+y2. I've done that years ago on Windows (which I "borrowed" some OpenGL code I found), yes, and I also borrowed code that parses an equation. This would probably be my last program not ported to Android.

Thursday, April 25, 2013

Math Experiments Revisited

I fixed my Math Experiments app to accommodate for larger screens. (This is long overdue) Nowadays Android phones are at least the size of the Nexus or the Samsung Galaxy. Also fixed a few issues. I also added the pen-and-pencil arithmetic methods from Visual Math Quiz in there. Why can a live teacher teach you math (and other subjects) better than you reading text alone? One reason is teachers can do visual demonstrations better than dead text. Also, need another example for adding fractions or solving a linear system of equations? just punch in different numbers. Dead text can't do that.

Get it on Google Play

Friday, April 12, 2013

Visual Math Quiz revisited

Fixed to display better for bigger phones... it seems Android phones are converging to one size: the size of the Samsung Galaxy III and Nexus. Added more config options: time per question, number of questions and which operations to quiz.

Get it on Google Play

The arithmetic demos were originally written in now-so-passe Java applets. It has evolved quite a bit.

Wednesday, March 13, 2013

Vocabulary List Revisited

I made several new features to Vocabulary List.

Now you can search your list, and import/export your list. Export is simply sending an email with pipe-delimited text. You can send your phone vocabulary list by gmail, with a subject "Vocabulary List - " followed by a list name. Call it "chapter 1" or "study words" or something. The content can be a list of words, or pipe-delimited vocabulary|definition.

For example:

ryu|japanese karate guy
ken|american karate guy
guile|the army guile
honda|the sumo guy
Get it on Google Play

Wednesday, January 16, 2013

Capture phone screenshot

This is a great omission that pre-4.0 Android phones do not have a screen-capture function. Fortunately there is a way to do this, if you have SDK tools installed: See here.

Screenshot can be captured with the ddms tool (Dalvik Debug Monitor).

Tuesday, January 8, 2013

Awesome blogger

This is an awesome Android blogger: Lots of useful examples and full source code. Thank you so much, Android-er.

Tuesday, May 15, 2012

Android Cloud to Device Messaging (C2DM)

It is easy to do "pull" from Android (or anything). Just use an http request. What about "push"? How do you send a message to your phone? There is the Cloud-to-Device-Messaging API. (Sure you can have a thread to periodically listen for messages intended for your phone too).

The link above is nice. It tells you the nuts and bolts but alas, where are the simple examples? There are complex over bloated examples in there. I want something simpler and to the point!

This gentleman wrote a lot of great examples for a lot of things: Lars Vogella's C2DM Tutorial.

There are many examples out there too. But they want to use the Unix curl command. I am in Windoze, Ok?

Everyone just have to put chunks of code but not runnable simple code, and even if you follow exactly there are got-chas.

Here are the steps.
1) First, you'll need a google account and sign up for C2DM, and provide your package name like com.mycompany.myapp

2) In your app, set up the manifest with all sorts of permissions as shown in the google c2dm link. You need a C2DMReceiver class that handles registration and messages sent to you.

3) To send message, you need 3 things.
1. Register on the phone to get a registration String from the C2DM Handler.

The 4 lines seen in google c2dm link works wonders. You need to somehow have the phone communicate this back to the sender application. (Vogelle send this to himself with http Post) I just System.out.println and captured it. You can probably send a email to yourself or something (silently).

2. An authorization ID from google ClientLogin given your google login/password, the form action is

Account Type:

See that Auth ID? copy it.

3. The message itself, of course

4) Now you can write a separate program to send message to your phone with the 2 IDs above and the message. Vogelle's MessageUtil work well. I added this method, and run the class as a command line app.

 public static void main(String args[]) {
  String auth_token="...";    // you supply yours here (step 3.1)
  String registrationId="..."; // you supply yours here (step 3.2)

  String message="something";
  if (args.length>0) {
  int status=0;
  try {
  status = sendMessage(auth_token,registrationId,message);
  } catch (Exception e) {
  System.out.println("Done sending, status="+status);
5. Final note, if you see an error in logcat saying something like the following:
ERROR/TalkProvider(232): java.lang.IllegalArgumentException: the bind value at index 2 is null
Turn off your google talk on your phone. Apparently google is using google talk as the way to send message to your phone.