Visualizzazione post con etichetta j2me. Mostra tutti i post
Visualizzazione post con etichetta j2me. Mostra tutti i post

lunedì 12 ottobre 2009

Check if a J2ME application has been sent to background correctly

Some device allow to put a J2ME application in background with this piece of code:
display.setCurrent(null);

To check if the cal was succesfull, we can use the isShown() method of the class displayable. So if m_disp is your displayable you can use:

if ( m_disp.isShown() ) {
    // method didn't work
 }
 else {
    // app is in background
 }

lunedì 21 settembre 2009

New Opera Mini5 Beta is online

The software is downloadable from http://m.opera.com/next. As stated in the Opera Mini Blog, the new main features are:


  • New, sleek design

  • Tabbed browsing

  • Password manager

  • Inline text editing

  • Copy-and-paste function

  • We have made a special, native version for BlackBerry which includes opening links and copy-and-paste functions


At a first glance the new graphic is really nice!

Opera Mini 5 beta

giovedì 12 marzo 2009

Utility application to monitor your j2me application power consumption

Screenshot0202On 9 March Nokia released the version 1.2 of Energy profiler a Symbian application you can use to monitor how the power consumption of your phone changes when you try a J2ME application (or other type of software).

As stated in the Nokia website:
"It is an application that enables developers and device users to examine power consumption and several other parameters on S60 devices. The reporting provided by the Nokia Energy Profiler enables developers to identify and improve application functions that consume excessive amounts of power and thus to create higher-quality applications."

The application works on Nokia series60 3rd and 5th edition devices.

The features added in the version 1.2 are:




  • Touch UI support.

  • Capture of WLAN received signal strength and 3G cellular network T1 and T2 timers.

  • New graphing features.

  • New CSV output features.

giovedì 5 marzo 2009

Minor release for Opera Mini J2ME.


The Opera Mini version 4.2.13918 is online ready for the download. This is a minmal release with small changes and bug fixing:


  • support for South Africa's English;

  • support for Guatemala's Spanish;

  • change in bookmark;

  • new default search engine for Ukraine (from Google to Yandex);

  • minor bugs fixing;

For the download click here

venerdì 30 maggio 2008

Google Android UI shown in SanFrancisco


Google showed off the new Android user interface in San Francisco during a developer conference. The demo has been done using a prototype device provided by an unamed manufacturer.

The interaction between user and device is in IPhone style...everything is drivable with a finger.

Watch the Steve Horowitz (Engineering director) presentation video:



lunedì 29 novembre 1999

Google Maps now with Street View

Google announced the adding of new features to their Google Maps on Wednesday 17th. The most important is Street View coming with the same street-level imagery available on desktop. You can use the Street View feature clicking on the apposite command after a search or clicking on a map and selecting "Street View".


Another interesting feature is the introduction of the business reviews: now it is possible know in advance if visit a store worths or not.


Also the walking directions introduced recently in the desktop version are available in the mobile application.


The search speed and the accuracy of the location has been also improved. Users with J2ME phone and BlackBerry can now enjoy the new features!


 




J2ME "on device debugging" with Sony Ericsson SDK

The Sony-Ericsson SDK provides you a tool to perform an on-device debugging of your J2ME applications.



After the SDK installation you can go to "Start" -> "Sony Ericsson" -> "Java ME SDK for CLDC"  and check the presence of two tools: "Connection Proxy" and "Device Explorer".



First of all you have to connect your Sony-Ericsson mobile phone to your pc. Launch "Connection Proxy" and press the "Settings" icon in the buttons bar. Select the COM port where your phone is connected to and press "Ok". Press "Connect" at the right top in the Connection Proxy software window. The "Status" frame below the device image should show the "Connected" status for your device.

Conn Prox settings



Now launch the Device Explorer. It should start the synchronization with your phone. If it doesn't, start it manually clicking the "Reloading device information" in the buttons bar.

After a while in the left column you should see the list of application installed in your device. Now you can select the application you want to debug and start it.



The System.outy.print messages included in your code will be shown in the console window at the bottom of the "Device Explorer" software.

Device explorer_1



The tool can be used also to manage the application: install, delete, stop, pause, and resume it.

Serializing an image with J2ME

Sometimes you need to transfer an image from your J2ME application to a server. In that case you need to serialize the image so you can write its bytes onto the connection opened with the server.

A good example to perform this task is in the Sony Ericsson Developer Site. Check out the article at developer.sonyericsson.com/site/global/techsupport/tipstrickscode/java/p_java_0502.jsp

Sony-Ericsson C905: first Capuchin phone

Sony-Ericsson has announced the new phone C905, the first phone supporting the project Capuchin (which define a bridge between J2ME and Flash). It is also equipped with an 8.1 megapixels camera and GPS. The screen resolution is 320x240.



It belongs to the JP-8 Sony-Ericsson family and it introduces a new subset called JP-8.4 which includes the phones of the JP-8 family supporting the project Capuchin.


It will be available on the selected markets during Q4 2008.


Sony-Ericsson C905


J2ME Google Maps API

I've found this interesting article from the wiki of Forum Nokia describing a library to query Google Maps to geocode addresses to their geographic coordinates and to retrieve static images with custom size, zoom and format.

The article is complete with source code and shows also an utility to scroll the map you get from Google

Go to the article clicking J2ME Google Maps API

Google maps example

Update to JP-8 family

In the Sony-Ericsson developer website we can find an useful article about their JP-8 platform that at the moment includes 14 devices.

 The most innovative supported API by this family are the Content Handl
er APIs(JSR-211) and the Mobile Sensor APIs (JSR-256).

Sensor APIs can be used to get the network signal or the battery level.


Battery
SensorInfo[] infos = SensorManager.findSensors("battery_charge", null);
String sensorURL =infos[0].getUrl();

Network signal
SensorInfo[] infos = SensorManager.findSensors("network_field_intensity", null);
String sensorURL =infos[0].getUrl();

The Content Handler APIs can be used to launch the native music player to play an audio file.

Registry registry = Registry.getRegistry(this.class.getName());
Invocation invoc = new Invocation();
invocation.setID("com.sonyericsson.musicplayer");
invoc.setURL(file:///..../playlist.m3u); //optional, if not used a resume play will be made.
invoc.setResponseRequired(true);
boolean mustExit = registry.invoke(invoc);
if (mustExit) {
// App must exit before invoked application can run
destroyApp(true);
notifyDestroyed();
} else {
// Application does not need to exit
}

You can read more about this topic in the Sony-Ericsson Developer Site

The new Opera mini 4.1 is available!

Get Opera Mini

After a month of beta-testing, the new Opera Mini 4.1 is available for the download (Opera Mini website).

It is possible have a guided tour of the software:click video tour.

Opera4.1_2

The new features, described in the Opera website pages, are:

More speed

Prior to this release, we upgraded our servers and Opera Mini now receives your requested Web pages up to 50% faster. So you can now access sites like Facebook, BBC, and any of your other favorite Web sites even faster, with Desktop-like speeds. 

Find things faster


The new Opera Mini 4.1 lets you search for text within a Web page so you can get to the information you need even quicker than before.


Get to your Web sites faster


When typing Web addresses, Opera Mini 4.1 will recognize and suggest completions for you based on your Bookmarks and browsing history, making address input faster, easier and much more intuitive.


Download and upload files


On phones with File connection API, you can now upload and download files using Opera Mini 4.1, without being re-routed to your phone’s native browser. Update your blog while on the go. Upload photos to your Web site or social network. Add attachments easily to Web-based email, and download other non media-rich content to your phone using Opera Mini 4.1.


Save it for later


On phones with File Connection API, Opera Mini 4.1 lets you save pages for offline viewing so you can quickly access and read your desired Web content, even when you’re on a plane, in the subway, or in other places where you can’t get network reception. Depending on your phone, you may need to choose a destination folder for storing pages for offline viewing.


Now, we have only to try it!




Opera4.1_1



 




The J2ME graphic library LWUIT becomes Open Source

LWUIT Open SourceThe LWUIT project is now Opens Source as announced in the blog of the project. Now the new features/bug fixings will be commited diectly to the repository and they will be immediately available for the developers that can also contribute directly to the project.



Main features of the new drop/source code include the following:



  • Live drag and drop support for components in layouts

  • Component z-ordering support

  • New absolute/scalable layout allowing arbitrary positioning

  • SVG Image support using JSR 226 - SVG Images can be loaded and applied to any component

  • 3D transitions are now possible for all components including dialogs and arbitrary components

  • Performance improvements: Added the ability to repaint a dirty rectangle within a Component

  • Added support for glass pane allowing a painter/painter chain to draw on top of the current component very efficiently.

  • Fix for issue of layering modal dialogs one on top of the other


About the license of the library they say: "The license we picked is the GPL+Classpath Exception which allows binary linking with the application (unlike the LGPL) thus allowing you to build and obfuscate your own proprietary applications. We still intend to offer binary drops under the current binary license to give you a choice between two licenses and ease your interaction with the legal department in your respective corporation (note that the binary license only applies to the binary drops!)."

LG KE970 Shine bug using MediaPlayer and setVolume

If you want to set the volume in the MediaPlayer using the following code:



                InputStream is = getClass().getResourceAsStream( "/sound.amr" );

                Player player = Manager.createPlayer(is, soundType);

               
player.addPlayerListener( this );

               
player.realize();

                VolumeControl volumeControl =

                (VolumeControl)
player .getControl( "VolumeControl" );

                if ( volumeControl != null ) {

                    volumeControl.setLevel( volume );

                }



when you launch the player with:



                player.start();



no sound can be heard on the LG KE970 Shine without getting any error.



This device requires to get the prefetched status if you want to set the volume and play the sound correctly. The working code is then:





                InputStream is = getClass().getResourceAsStream( "/sound.amr" );

                Player player = Manager.createPlayer(is, soundType);

               
player.addPlayerListener( this );

               
player.realize();

               
player.prefetch( );

                VolumeControl volumeControl =

                (VolumeControl)
player .getControl( "VolumeControl" );

                if ( volumeControl != null ) {

                    volumeControl.setLevel( volume );

                }




Maybe other phones are affected as well (especially LG). Post comment if you other phones with the same problem.

Nokia Serie60 and 40 bug: softkey codes are not reported on a normal Canvas


Forum Nokia Logo

This bug is reported by forum.nokia.com in their "Knowledge Base" section.

Some key codes are not reported through the keyPressed(), keyRepeated(), and keyReleased (
methods of the Canvas class on a normal, non-full screen Canvas. This applies especially to the left, middle (when present), and right softkeys. Those are only reported back to the above key-capturing methods on full-screen Canvas instances.

The MIDP 2.0 specification says:


For some devices the keys used for commands may overlap with the keys that will deliver key code events to the canvas. If this is the case, the device will provide a means transparent to the application that enables the user to select a mode that determines whether these keys will deliver commands or key code events to the application.


This does not happen on all tested devices.

The tested devices are
Nokia 6301, Nokia 6555, Nokia N95, Nokia E61i. The families affected are S40 5th Edition (and FP1) and S60 3rd Edition (and FP1 and FP2) .

J2ME system properties

Sometimes it is useful to know informations about the J2ME platform running in a devices. To get this data it is possible use the System class and its method getProperty().

Both standard properties and brand's specific properties exist.

At this URL:
www.forum.nokia.com/info/sw.nokia.com/id/37086440-dcce-4fb4-aa3e-8d8c16d62b33/MIDP_System_Properties_v1_2_en.zip.html


you can find a document from Nokia Forum where a list of system properties is shown. You'll see some specific Nokia properties also.

Detect softkey automatically

Surfing on Internet, I found this post in the Sony Ericsson Developer Forum. I've not tested it yet but it seems a good idea!

I'm going to test it in the next days....if someone wants do the same here is the link:


http://developer.sonyericsson.com/thread.jspa?threadID=41399&tstart=0

...in main class (Presentacion.java):

//Softkeys...
public static int LeftSoftKey = 0;
public static int RightSoftKey = 0;




...while a splash screen is showing:

Thread myThread = new ReturnSoftKeys();
myThread.run();



...in some point, inside the main class:

private class ReturnSoftKeys extends Thread{

public void run(){

try {
Class.forName("com.siemens.mp.lcdui.Image"); // Set Siemens specific keycodes
Presentacion.LeftSoftKey = -1;
Presentacion.RightSoftKey = -4;
} catch (ClassNotFoundException ignore) {

try {
Class.forName("com.motorola.phonebook.PhoneBookRecord"); // Set Motorola specific keycodes
if (getKeyName(-21).toUpperCase().indexOf("SOFT") >= 0) {
Presentacion.LeftSoftKey = -21;
Presentacion.RightSoftKey = -22;
} else {
Presentacion.LeftSoftKey = 21;
Presentacion.RightSoftKey = 22;
}
} catch (ClassNotFoundException ignore2) {
boolean found;

// check for often used values
// This fixes bug with some Sharp phones and others
try {
if (getKeyName(21).toUpperCase().indexOf("SOFT") >= 0) { // Check for "SOFT" in name description
Presentacion.LeftSoftKey = 21; // check for the 1st softkey
Presentacion.RightSoftKey = 22; // check for 2nd softkey
found=true;
}

if (getKeyName(-6).toUpperCase().indexOf("SOFT") >= 0) { // Check for "SOFT" in name description
Presentacion.LeftSoftKey = -6; // check for the 1st softkey
Presentacion.RightSoftKey = -7; // check for 2nd softkey
found=true;
}
}catch(Exception e) {}


for (int i=-127;i<127;i++) { // run thru all the keys
try {
if (getKeyName(i).toUpperCase().indexOf("SOFT") >= 0) { // Check for "SOFT" in name description
if (getKeyName(i).indexOf("1") >= 0) Presentacion.LeftSoftKey = i; // check for the 1st softkey
if (getKeyName(i).indexOf("2") >= 0) Presentacion.RightSoftKey = i; // check for 2nd softkey
}
}catch(Exception e){ // Sony calls exception on some keys

//I change this, the following lines will be commented
//Presentacion.LeftSoftKey = -6; // including softkeys
//Presentacion.RightSoftKey = -7; // bugfix is to set the values ourself
}
}
}
}
}
}



At this point, if the ReturnSoftKeys method failed, the values of the softkeys are 0. This could be because a exception crashes the method. Usually getKeyName

inside the keypressed method:

public void keyPressed(int code) {

int gameAction = getGameAction(code);
//bla bla bla

if (this.LeftSoftKey != 0 || this.RightSoftKey != 0){ //The ReturnSoftkeys method was a success

if (code == this.LeftSoftKey){

softKeyIzquierda();
}

else if (code == this.RightSoftKey){

softKeyDerecha();
}
}

//ReturnSoftKeys was a failure, looking for SOFT in the key name
else {

if (getKeyName(code).toUpperCase().indexOf("SOFT") >= 0) { // Check for "SOFT" in name description

if (getKeyName(code).indexOf("1") >= 0 || getKeyName(code).toUpperCase().indexOf("LEFT") >= 0){

softKeyIzquierda(); // check for the 1st softkey
}

if (getKeyName(code).indexOf("2") >= 0 || getKeyName(code).toUpperCase().indexOf("RIGHT") >= 0){

softKeyDerecha();
}
}

//the name of the key doesn't include "soft". for example if is in spanish: "tecla Accion" instead "soft" I assign the value manually
else{

if( code == (-6) || code == (-202) || code == (-21) || code == (-11)/* || code == (-1) */){

softKeyIzquierda();
}

else if(code == (-7) || code == (-203) || code == (-22)/* || code == (-4)*/){

softKeyDerecha();
}
}
}

repaint();

 

FileConnection API System properties


At this link, we can find several interesting J2ME system properties useful when we are working with File Connection API and we want know, for example, names and path of some directories.

The link is from Forum Nokia website but is a good start for all the devices supporting this optional package.

www.forum.nokia.com/document/Java_ME_Developers_Library_v1/GUID-545CA84A-8378-4DFA-9035-94479F5BE26E.html


Filesystem in Serie60 Emulator

When we are working with FileConnection API, it's good to have an easy way to put file in the file system of the emulator to test at least the read side of our midlets.

If we are using the Nokia Serie 60 3rd edition FP1 emulator we can find the filesystem at

C:NokiaDevicesS60_3rd_MIDP_SDK_FP1binepoc32winscwc

(supposing we have installed the SDK under C:).

If you enter in the "Data" folder, you can then see the folders for the files like Images, Sounds, etc.