Archive

Posts Tagged ‘java’

Android: Get String From Resource By Name

November 29th, 2009 niels No comments

Usually the string resources in your Android application are being referred to by a unique ID. But sometimes you will want to recover a string by its key, e. g. when you build the key of the string at the run time of your application (“Battery_Health_2″ or “Battery_Health_3″). You can do that like this:

private String getStringResourceByName(String aString)
{
  String packageName = "com.coliena.myapp";
  int resId = getResources().getIdentifier(aString, "string", packageName);
  return getString(resId);
}

Check this link if you need to recover in image resource by its name.
More information about string resources is available in the Android Developer Documentation.

Tags: ,

Java on Mac OS X 10.6 Snow Leopard

September 8th, 2009 niels No comments

Apple apparently set Java 6b14 (64 bit) as default in Snow Leopard, both in 32 and 64 bit Kernel environments.
They dumped Java 1.4 and Java 5, but you can switch to Java 6 (32 bit).

Tags: , ,