Thursday, October 14, 2010

Security policy error

run

Running…

Error launching remote program: security policy error.

Error launching remote program: security policy error.

The program being debugged is not being run.

The program being debugged is not being run.


If, when you are in the middle of debugging an app on iPhone or iPad, this error catches you, check the mobile provisioning profiles installed on the device and delete any ones that may be expired. Even though they would have nothing to do with the current project you are on, it blocks the device like a poison.

Monday, October 11, 2010

Hint: iPhone / iPad plist properties

If you are trying to add additional properties to the info.plist of a project, but the automatic plist type seems to be wrong, the fix for it is a simple trick.

ctrl-click the plist type to open as plain text file, then to text property list, and then from the menu select View > Property List Type > iPhone Info.plist.

If the values are not selectable, just repeat the process. It seems like a strange bug in Xcode.

Saturday, January 23, 2010

Simple internationalization / localization with LWUIT and JME

If you want your application in a range of languages, it is really simple using the LWUIT framework.


Create a resource file using the resource editor.

- create a new res file.

- select the L10N tab and click the plus button to create a new localization file (call it "Lang")

- add locale: "es".

- add property... and so on.


Note that the soft key bar labels must be defined in this file. For example when using a pop up menu, "Menu", "Select" and "Cancel" are displayed in the soft key bar. These should be localized using a resource file.


For example, add property "Menu", and for the locale "es", save as "MenĂº".

Key: "Select", value "Seleccionar". And so on.


For this example, save the resource file as "lang.res" and in the project, select Properties and then under build > Libraries and Resources, select "add folder".


In the midlet startApp method call:

try {

r = Resources.open("/lang.res");

UIManager.getInstance().setResourceBundle(r.getL10N("Lang", "es"));

} catch (IOException ex) {

ex.printStackTrace();

}


For each the labels used in the app, LWUIT can automatically set the language. Just remember the key used when setting the label:



Label myLabel = new Label(new String(“someKey”));


Note that if you use bitmap fonts, remember to include the letters with accents if you are using them. If you forget this, then words displayed will be missing those letters.


To know the locale of the handset use:


String defaultLocale = System.getProperty("microedition.locale");


This will return a string with a format of two lover case letters and to upper case ones.

Eg: en-US, es-ES.


Use the first 2 letters for the language in the res file.


if(defaultLocale.length > 2) {

defaultLocale = defaultLocale .subString(0,2);

}



UIManager.getInstance().setResourceBundle(r.getL10N("Lang", defaultLocale));


To test this out, go to the preferences in the WTK, select i18n and set the locale to "es-ES".



Other localizations issues can be handled by I18N API, if present. JSR 238 helps in date and currency formatting.


See http://www.ibm.com/developerworks/library/wi-globalapps/index.html