My blog has moved!

You should be automatically redirected in 6 seconds. If not, visit
http://kavachai.com
and update your bookmarks.

Monday, September 7, 2009

Have you tried turning it off and on again?

"Turn it off and on again" is almost as canonic recipe as "Ctrl-Alt-Del". Here is an excellent video about first from "The IT Crowd" series:

Tuesday, August 4, 2009

Bjarne Stroustrup's wish came true

Yesterday I saw a quotation of Bjarne Stroustrup:
I have always wished that my computer would be as easy to use as my telephone.
My wish has come true.
I no longer know how to use my telephone.

To my mind this three sentences show that sometimes marketing people can turn even the simplest thing to a swiss knife. And these electronic swiss knifes are not so intuitive in use.

Linkpool

I'd like to share some stuff that I read/listen recently:


I believe this post will be a start of regular sets of articles that I find really exciting and interesting.

Thursday, July 30, 2009

Installing & uninstalling applications on emulator

Story 1. Installing application.
To install application to emulator adb utility will be handy:
  • Start emulator.
  • Open command prompt (cmd.exe).
  • Navigate to "tools" directory in Android SDK.
  • Run installation using command "adb install application.apk". For example, "adb install "C:/com.andreware.sample.apk"" when com.andreware.sample.apk is located at root directory on disk C.
  • Wait couple of seconds while application is being installing.

Story 2. Uninstalling application.
There two ways to uninstall application from emulator: uninstall like on real device or use adb utility. First way allows to uninstall any application while adb utility will allow to uninstall only application installed using it (including the ones deployed from IDE).
Let's look at first one first. It is pretty simple and straitforward:
  • Start emulator.
  • On the home screen press the "Menu" button.
  • Choose"Settings" item from menu.
  • Choose "Applications" item in the settings list.
  • Choose "Manage applications".
  • Choose application that you want to uninstall.
  • In the "Application info" window that will appear click "Uninstall" button.
  • Confirm uninstalling.
  • Wait a second while application is being uninstalling and click "OK" on next window that says "Uninstall finished".
Second way requires usage of command line and adb utility:
  • Start enulator.
  • Open command window (cmd.exe).
  • Navigate to "tools" directory in Android SDK.
  • Run remote shell: "adb shell".
  • Goto app directory: "cd /data/app".
  • Now you can list installed applications: "ls".
  • To uninstall application use "rm" command and appropriate apk file. For example, "rm com.andreware.sample.apk".
  • Type "exit" to leave remote shell.

Using Android standard icons in designer

Today I wanted to use standard search icon on one of the buttons. When I want to use custom icon I use Reference Chooser dialog. As a result I have such a reference in a property:
@drawable/search_icon
But Reference Chooser dialog does not provide a way to use standard icon (or I don't see it). Fortunately we can type reference directly to property value either in designer or plane xml. So to use standard drawables "@android:drawable/id" pattern can be used. For example, to set standard search icon I used this reference text:
@android:drawable/ic_menu_search

Wednesday, June 17, 2009

Setup Eclipse for BlackBerry Storm development

I've spent many hours trying to install BlackBerry plug-in v4.7 (needed to develop for Storm) on Eclipse and finally I found solution. As always solution was in one small detail. Here is the whole way to setup environment.

INSTALL J2SE
Download and install Java SE Development Kit. Personally I used JDK, but I think JRE should work as well.

INSTALL ECLIPSE
Download and install (actually unpack) Eclipse IDE for Java Developers if you don't have one. I must say that BlackBerry plug-in for Eclipse contains this IDE, but who knows what version did they pack into plug-in installer.

DOWNLOAD COMPLETE ECLIPSE SOFTWARE UPDATE
Once you checked that your Eclipse is working you need to install BlackBerry Eclipse plug-in. Go to BlackBerry JDE Plug-in for Eclipse and download Full Installer and Eclipse Software Update for the BlackBerry JDE v4.7 Component Pack.

INSTALL ECLIPSE BLACKBERRY PLUGIN
Install plug-in from Full Installer first. It will ask you to install new Eclipse or specify existing one. Just point to your Eclipse folder and proceed installation process.
Since Full Installer does not provide you with Storm emulator and v4.7 platform you need to install v4.7 Component Pack. RIM web site suggests to install this update using update site. Don't do it. If you already tried to go this as discribed in instructions you will need to perform step 4. Here is correct way to install update:
  1. 1. Run Eclipse
  2. 2. Go to Help > Software_Updates
  3. 3. Switch to Available_Software tab
  4. 4. Make sure that you don't have a link to "http://www.blackberry.com/go/eclipseUpdate" there. If you have follow step 4.1 otherwise jump to step 5.
    • Remove link to RIM update site using Manage_Sites button.
  5. 5. Add new site like this:
    • Click Add_Site button.
    • Click Archive button and select update file downloaded earlier.
    • Click OK.
  6. 6. Check this new node in the list of available software and click Install button.
  7. 7. Follow instructions in installer.

SETUP ECLIPSE TO USE BLACKBERRY 4.7 JDK
Now you will have 4.7 installed, but not set as default. You need to change default component from 4.5 to 4.7.
To do so you need to:
  • Create new workspace and add BlackBerry project (File > New > Project and pick BlackBerry project).
  • Go to BlackBerry > Configure_BlackBerry_Workspace in Eclipse main menu.
  • Navigate to BlackBerry_JDE > Installed_Components
  • And change component from 4.5 to 4.7

That's it. Now you can start playing with Eclipse environment for BlackBerry.

P.S.
There are some problems with simulator under Eclipse. I wrote about this in BlackBerry simulator in Eclipse could work better.

There is no "enum" keyword for BlackBerry

In one of projects I'm working on I needed to port some code from Android to BlackBerry platform. As part of implementation for Android I used enumeration.
As I saw there is no "enum" keyword for BlackBerry. That was hard to understand since I like enums as a natural way to group constants. Anyway I had two options: use simple constants or design a class. I decided on the second one.

So for enum that looks like this:
enum Numers {
Odd, Twin;

public int toInt() {
return (this == Odd) ? 0 : 1;
}

public static Numbers fromInt(int value) {
return (value == 0) ? Odd : Twin;
}
}
I used class like this:
class Numbers {
public static Numbers Odd = new Numbers(0);
public static Numbers Twin = new Numbers(1);

private int _value;

private Numbers(int value) {
_value = value;
}

public int toInt() {
return this._value;
}

public static Numbers fromInt(int value) {
return (value == 0) ? Odd : Twin;
}
}
Not so natural as with "enum" keyword, but good enough :)