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):
...while a splash screen is showing:
...in some point, inside the main class:
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:
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();
Nessun commento:
Posta un commento