Javaground provides Xpress Suite which ports a singla Java source code into Brew, iPod Touch/iPhone, Android. Sounds amazing but I never got to try it. But you can try it and get more info from here:
http://www.javaground.com/
Wednesday, 26 August 2009
Sunday, 23 August 2009
Application not compatible with phone error
Application not compatible with phone error happen because it is not set to the proper settings supported by the phone. It is a runtime error which means it would only happen if you run it on the phone itself.
To overcome this problem, you need to find out the CLC and MIDP version supported by the phone through Google etc. For example, if the phone supports CLDC 1.1 and MIDP 2.0, select that as the settings in your IDE(eg Netbeans,Sun Wireless Toolkit). Then, compile the code and run it in the phone. It should work now.
If not, another possibility is that you are using a JSR which the phone does not support. You can again google the JSR which your phone supports.
To overcome this problem, you need to find out the CLC and MIDP version supported by the phone through Google etc. For example, if the phone supports CLDC 1.1 and MIDP 2.0, select that as the settings in your IDE(eg Netbeans,Sun Wireless Toolkit). Then, compile the code and run it in the phone. It should work now.
If not, another possibility is that you are using a JSR which the phone does not support. You can again google the JSR which your phone supports.
Wednesday, 29 April 2009
Initiating a phone call in Blackberry
Lets say you wish you make your application to attempt to make a call in Blackberry. This is how you do it.
PhoneArguments pa = null;
pa = new PhoneArguments(PhoneArguments.ARG_CALL,"67838763520");
Invoke.invokeApplication(Invoke.APP_TYPE_PHONE, pa);
The bolded part is the number you wish to make a call to.
You might also want to check for any active calls before making a call. So here it is:
private static boolean gotActiveCall() {
boolean callExist = false;
if(Phone.getActiveCall() != null) {
callExist = true;
}
return callExist;
}
PhoneArguments pa = null;
pa = new PhoneArguments(PhoneArguments.ARG_CALL,"67838763520");
Invoke.invokeApplication(Invoke.APP_TYPE_PHONE, pa);
The bolded part is the number you wish to make a call to.
You might also want to check for any active calls before making a call. So here it is:
private static boolean gotActiveCall() {
boolean callExist = false;
if(Phone.getActiveCall() != null) {
callExist = true;
}
return callExist;
}
BlackBerryContact Names
Getting the name of a BlackBerryContact has been been this easy... :)
This method takes in a BlackBerryContact as the argument and would return the name as a String.
private String getDisplayName(BlackBerryContact contact) {
StringBuffer buf = new StringBuffer();
String[] name = contact.getStringArray(BlackBerryContact.NAME, 0);
//Get the prefix, first and last name
boolean found = false;
String nameseg;
// Catch each field separately to make sure we get any available fields
try {
if((nameseg = name[BlackBerryContact.NAME_PREFIX]) != null && nameseg.length() != 0) {
buf.append(nameseg);
found = true;
}
} catch(IndexOutOfBoundsException ignore) {}
try {
if ((nameseg = name[BlackBerryContact.NAME_GIVEN]) != null && nameseg.length() != 0) {
if(found) {
buf.append(' ');
buf.append(nameseg);
found = true;
}
}
} catch(IndexOutOfBoundsException ignore) {}
try {
if((nameseg = name[BlackBerryContact.NAME_FAMILY]) != null && nameseg.length() != 0) {
if (found) {
buf.append(' ');
}
buf.append(nameseg);
found = true;
}
} catch(IndexOutOfBoundsException ignore) {}
//This is to get the Company if no names are found under the Contact
try {
if (found == false) {
buf.append(contact.getString(BlackBerryContact.ORG, 0));
}
} catch(IndexOutOfBoundsException ignore) {}
return buf.toString();
}
This method takes in a BlackBerryContact as the argument and would return the name as a String.
private String getDisplayName(BlackBerryContact contact) {
StringBuffer buf = new StringBuffer();
String[] name = contact.getStringArray(BlackBerryContact.NAME, 0);
//Get the prefix, first and last name
boolean found = false;
String nameseg;
// Catch each field separately to make sure we get any available fields
try {
if((nameseg = name[BlackBerryContact.NAME_PREFIX]) != null && nameseg.length() != 0) {
buf.append(nameseg);
found = true;
}
} catch(IndexOutOfBoundsException ignore) {}
try {
if ((nameseg = name[BlackBerryContact.NAME_GIVEN]) != null && nameseg.length() != 0) {
if(found) {
buf.append(' ');
buf.append(nameseg);
found = true;
}
}
} catch(IndexOutOfBoundsException ignore) {}
try {
if((nameseg = name[BlackBerryContact.NAME_FAMILY]) != null && nameseg.length() != 0) {
if (found) {
buf.append(' ');
}
buf.append(nameseg);
found = true;
}
} catch(IndexOutOfBoundsException ignore) {}
//This is to get the Company if no names are found under the Contact
try {
if (found == false) {
buf.append(contact.getString(BlackBerryContact.ORG, 0));
}
} catch(IndexOutOfBoundsException ignore) {}
return buf.toString();
}
BlackBerryContact Phone Numbers
Retrieving BlackBerryContact phone numbers and the labels then showing it in a dialog to let user to choose.
BlackBerryContact c;
Find out the number of phone numbers saved under a contact
c.countValues(BlackBerryContact.TEL);
Setup variables to hold the numbers and their labels.
phoneNumbers = new String[phoneCount];
labels = new String[phoneCount];
String label = "";
Go through a loop to get the numbers and find out the label
for(int i = 0; i < phoneCount; i++)
{
//Fetch the phone number
String phoneNumber = c.getString(BlackBerryContact.TEL, i);
//Determine the label for that number
if(c.getAttributes(BlackBerryContact.TEL,i) == BlackBerryContact.ATTR_MOBILE)
{
label = "mobile";
}
else if(c.getAttributes(BlackBerryContact.TEL,i) == BlackBerryContact.ATTR_WORK)
{
label = "work";
}
else if(c.getAttributes(BlackBerryContact.TEL,i) == BlackBerryContact.ATTR_HOME)
{
label = "home";
}
//Add the number and label to the array.
phoneNumbers[i] = phoneNumber;
labels[i] = label;
}//end of for loop
Display the number in a Dialog.ask
StringBuffer sb = new StringBuffer();
//If more than one numbers found
if(phoneCount > 1)
{
int choice = Dialog.ask("Which number to use?",labels,0);
if (choice == 0)
{
sb.append(phoneNumbers[0]);
}
else if (choice == 1)
{
sb.append(phoneNumbers[1]);
}
else if (choice == 2)
{
sb.append(phoneNumbers[2]);
}
else if(choice == Dialog.CANCEL)
{
sb.append("CANCEL");
}
}
BlackBerryContact c;
Find out the number of phone numbers saved under a contact
c.countValues(BlackBerryContact.TEL);
Setup variables to hold the numbers and their labels.
phoneNumbers = new String[phoneCount];
labels = new String[phoneCount];
String label = "";
Go through a loop to get the numbers and find out the label
for(int i = 0; i < phoneCount; i++)
{
//Fetch the phone number
String phoneNumber = c.getString(BlackBerryContact.TEL, i);
//Determine the label for that number
if(c.getAttributes(BlackBerryContact.TEL,i) == BlackBerryContact.ATTR_MOBILE)
{
label = "mobile";
}
else if(c.getAttributes(BlackBerryContact.TEL,i) == BlackBerryContact.ATTR_WORK)
{
label = "work";
}
else if(c.getAttributes(BlackBerryContact.TEL,i) == BlackBerryContact.ATTR_HOME)
{
label = "home";
}
//Add the number and label to the array.
phoneNumbers[i] = phoneNumber;
labels[i] = label;
}//end of for loop
Display the number in a Dialog.ask
StringBuffer sb = new StringBuffer();
//If more than one numbers found
if(phoneCount > 1)
{
int choice = Dialog.ask("Which number to use?",labels,0);
if (choice == 0)
{
sb.append(phoneNumbers[0]);
}
else if (choice == 1)
{
sb.append(phoneNumbers[1]);
}
else if (choice == 2)
{
sb.append(phoneNumbers[2]);
}
else if(choice == Dialog.CANCEL)
{
sb.append("CANCEL");
}
}
Friday, 3 April 2009
Processes and Port Numbers
Need to find out what process is using a certain port? Use CurrPorts! Download it here. Download the whole zip file and extract it. There would be a number of programs inside. Open up CurrPorts and it would list all the processes using the respective port numbers.
To kill the process:
Now that you know what is the process, open Task Manager(CTRL + ALT + DEL) and search for the process. Select it and press End Process.
:)
I had to use this because there was a port being used and I could not do On-Device Debugging to my Sony Ericsson JP-8 phone. So this might help some of you people out there!
To kill the process:
Now that you know what is the process, open Task Manager(CTRL + ALT + DEL) and search for the process. Select it and press End Process.
:)
I had to use this because there was a port being used and I could not do On-Device Debugging to my Sony Ericsson JP-8 phone. So this might help some of you people out there!
Thursday, 2 April 2009
Minimizing MIDlets in Sony Ericsson
To check if a MIDlet is minimized, the Displayable.isShown() method can be used. It is of course preferable to check for a minimized MIDlet this way:
private boolean isOnBackGround(){
boolean isOnBackGround =(BubbleTalk.getDisplay().getCurrent() == null ||
!BubbleTalk.getDisplay().getCurrent().isShown());
return isOnBackGround;
}
For more information regarding minimizing MIDlets in Sony Ericsson, click here.
private boolean isOnBackGround(){
boolean isOnBackGround =(BubbleTalk.getDisplay().getCurrent() == null ||
!BubbleTalk.getDisplay().getCurrent().isShown());
return isOnBackGround;
}
For more information regarding minimizing MIDlets in Sony Ericsson, click here.
Subscribe to:
Posts (Atom)