Frage

I am building an application of telephone directory. I am using lwuit for ui building, so my application is running at MIDP2.1 and CDLC1.1. The application is targeted for nokia s40 devices.

When I am calling the platformRequest method from my form class with a constant number like this piece of code below, where StartApp is my main MIDlet.

     try 
        { 
    if (StartApp.getInstance().platformRequest("tel:01239201300") == true)
          {
            StartApp.getInstance().notifyDestroyed();
          }
       }
     catch(Exception ex)
     {
        System.out.println(ex);
     }

The application runs correctly and a call request is generated, but if I try to do this work like this piece of code below

   try{   
     String number = "tel:" + lblTelNumber.getText();
        System.out.println(number);
        if (StartApp.getInstance().platformRequest(number) == true)
        {
            StartApp.getInstance().notifyDestroyed();
        }
     }
   catch(Exception ex)
    {
        System.out.println(ex);
    }

This results in the following exception.

ordinary platformRequest: tel:01239201300 
URL is : tel:01239201300 
javax.microedition.io.ConnectionNotFoundException: Invalid Phone Number
at javax.microedition.midlet.MIDlet.platformRequest(+76)
at package1.InformationForm.Call(+48)

I don't know what is the problem here?

War es hilfreich?

Lösung

There is a chance to have invisible symbols (eg trailing spaces) in your second code snippet.

To find out whether it's so, modify your debugging message to something like System.out.println("[" + number + "]"), re-run your test and re-check the output.

update

It seems like there is a new line character at the end of number, the number appears in comment as, [tel:01239201300 ] (The second bracket is appearing in next line in comment).

Well that alone seem to be pretty sufficient to get Invalid Phone Number.

API documentation for MIDlet.platformRequest refers to RFC2806, for phone number URLs, which appears to pretty strictly specify what is allowed and what is not in section 2.2 "tel" URL scheme.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top