Geek T-Shirt Collection #21 – Google

I got this during my “Google fanboy period”. Now I’m a little more critical. I’m now going through an “Android fanboy period”.

There’s a funny story of this shirt. The first day I moved to Miami I was running an errand in downtown and some lady yelled at me from the other side of the street and told me “I use your page every day!”, I didn’t break her heart and just yelled back “Thanks!”

See the Previous T-Shirt
See the Next T-Shirt

[SOLVED] Eclipse can’t see my Android Device on Ubuntu

Are you seeing this on eclipse when you plug your Android device to your Ubuntu box?

Serial Number: ??????????
AVD Name: N/A
Target: unknown
State: ??

Here’s the solution:

1. Create a script to fix this next time it happens, let’s call it “android_device_reset” and save it on a folder contained on your $PATH environment variable.

[bash]
#!/bin/bash
# android_device_reset script
sudo adb kill-server
sudo service udev stop
sudo adb start-server
sudo adb devices
[/bash]

Save it and make it executable
[bash]chmod +x android_device_reset[/bash]

2. Open this file /etc/udev/rules.d/51-android.rules

Make sure it looks something like this
[bash]
SUBSYSTEMS=="usb", SYSFS{idVendor}=="0bb4", MODE=="0666"
SUBSYSTEMS=="usb", SYSFS{idVendor}=="22b8", MODE=="0666"
[/bash]

Each line represents a different android device. If you have just one, the file should be one line long.

On that example I’ve configured the rules for a Motorola Droid and a Nexus One.
If you need to know the idVendor numbers for your Android device go here
developer.android.com/guide/developing/device.html#VendorIds

3. Whenever the problem happens, just open a terminal and type
[bash]android_device_reset[/bash]

It’ll ask you for your password, only administrative users will be able to execute the script.

Hope this helps.

Nokia N900 vs Nexus One vs Droid: HD Video Playback comparison

Grabbed the demo video that comes with the N900 to delight you and put it on the 3 phones.

The screen on the Nexus One is the most impressive.

The Droid has a 1/2 sec. lag when you try to jump to another part of the video.

If you don’t care about the screen being so vibrant N900 is just as good doing video playback comparing it with the Nexus One.

Droid vs Nexus 1: Who can calculate MD5 faster?

Nexus 1 indeed.


17 files get their MD5 calculated on the Droid


and 17 files get their MD5 hash calculated on the Nexus 1

Nexus 1 pwns.

Here’s the code in case you’re curious.
[java]
public void onClick(View v) {
_logTextView.setText("MD5 Benchmark on " + Build.DEVICE + "nn");
if (GlobalVariables.APP_CONTEXT == null)
GlobalVariables.APP_CONTEXT = getApplicationContext();

List<FileDescriptor> sharedAudioFiles = Engine.INSTANCE.LIBRARIAN.getSharedAudioFiles(0, 17);
for (FileDescriptor fs: sharedAudioFiles) {
long start = 0;
String md5 = null;
long length = 0;
try {
start = System.currentTimeMillis();
File f = new File(fs.path);
length = f.length();
md5 = FrostWireUtils.getMD5(f);

} catch (Exception e) { }
long time = System.currentTimeMillis() – start;
_logTextView.append(FrostWireUtils.getBytesInHuman(length) + " in " + time + " ms @ " + (length/(double) time)*1000 + " b/sn");
}
}
[/java]

And here’s how we do the MD5
[java]
public final static String getMD5(File f) throws Exception {
MessageDigest m = MessageDigest.getInstance("MD5");

byte[] buf = new byte[65536];
int num_read;

InputStream in = new BufferedInputStream(new FileInputStream(f));

while ((num_read = in.read(buf)) != -1) {
m.update(buf, 0, num_read);
}

String result = new BigInteger(1, m.digest()).toString(16);

// pad with zeros if until it’s 32 chars long.
if (result.length() < 32) {
StringBuffer padding = new StringBuffer();
int paddingSize = 32 – result.length();
for (int i = 0; i < paddingSize; i++)
padding.append("0");

result = padding.toString() + result;
}

return result;
}
[/java]

[SCREENCAST] How to do Unit Testing on Android with Eclipse

I was going to make a tutorial, but then I figured that making a video would be a much better way to show this.
As for the code that you could grab from a tutorial, there’s a link at the end of the post with all the code shown in the video demo.

The video demo covers how to create and run Unit Test classes for regular Java classes on Android, and also how to create and run Unit Test classes that test classes that depend on Android “Context” or “Activity” objects.

If your Android unit tests are not running because of frustrating error messages, the time spent watching this video will save you a lot of reading and headaches.

Check the screencast after the break

Continue reading