Home  | My Account  |  Membership
WorldDeveloper.org
Forum Details
Topics
Posts
Categories
 
577 member(s)
718,905 hit(s)
14 categories
51 topics
26 messages
0 online
Forums: J2ME Development
Detecting Soft Keys
hostj2me
43 topic(s)
23 post(s)

November 06, 2007 8:17 PM

Here is the pseudo code I use to determine the soft key assignments in most of my J2ME apps.


int KEY_SOFTKEY_LEFT = -6;
int KEY_SOFTKEY_RIGHT = -7;

if ( ...check needed )
{
try
{
Class.forName("com.siemens.mp.game.Light");
KEY_SOFTKEY_RIGHT = -4;
KEY_SOFTKEY_LEFT = -1;
}
catch (ClassNotFoundException ignore)
{
//ignore.printStackTrace();

try
{
Class.forName("com.mot.iden.customercare.CustomerCare");
KEY_SOFTKEY_RIGHT = -21;
KEY_SOFTKEY_LEFT = -20;
}
catch (ClassNotFoundException ignore2)
{
//ignore2.printStackTrace();

try
{
Class.forName("com.motorola.phonebook.PhoneBookRecord");
KEY_SOFTKEY_RIGHT = -22;
KEY_SOFTKEY_LEFT = -21;
}
catch (ClassNotFoundException ignore3)
{
if ( someCanvas.getKeyName(-21).equalsIgnoreCase("soft1") )
{
KEY_SOFTKEY_LEFT = -21;
}

if ( someCanvas.getKeyName(-22).equalsIgnoreCase("soft2") )
{
KEY_SOFTKEY_RIGHT = -22;
}
}
}
}
}


©2008 WorldDeveloper.org - PO Box 310575 Miami, FL 33231

WorldDeveloper.org is a managed social network for application developers around the world.