0

電話番号をダイヤルするコードを 2 日間書き込もうとしましたが、失敗しました

私はミッドレットとメインと呼ばれるフォームを Displayable として作成しました。フォームにはテキストフィールドが含まれており、

指図 。

アプリケーションが起動すると、フォームが表示され、記載されているダイヤル番号を呼び出す必要があります。

コマンドが押されたときの textField。

ダイヤル プロセスが機能しませんでした。

import javax.microedition.io.ConnectionNotFoundException;

import javax.microedition.lcdui.Command; 

import javax.microedition.lcdui.CommandListener;
import javax.microedition.lcdui.Display;
import javax.microedition.lcdui.*;
import javax.microedition.lcdui.Displayable.*;
import javax.microedition.lcdui.Form.*;
 import javax.microedition.midlet.MIDlet;
 import java.io.IOException;
 import java.io.InputStreamReader;
 import javax.microedition.lcdui.*;
 import javax.microedition.midlet.MIDlet;

public class DiallNumber extends MIDlet implements CommandListener
 {
    String num;
 private  Form main;
 private Command call,dial;
 private TextField phoneField;

 Display display;

 public DiallNumber()
    {


 main = new Form("main");
phoneField = new TextField("label","",10,phoneField.PHONENUMBER);
call = new Command("call",call.OK,0);
    main.append(phoneField);
    main.addCommand(call);
    num=this.phoneField.getString().trim();
main.setCommandListener(this);
 }

/**}
 * From MIDlet. Called when the MIDlet is started.
 */
 public void startApp()
 {

 // The initial display is the first form

display = Display.getDisplay(this);
   display.setCurrent(main);





     }

public void call( String number) {
 try {
 platformRequest("tel:"+number);
 } catch (ConnectionNotFoundException ex) {
 // TODO: Exception handling
 }
 }
 public void commandAction(Command c, Displayable d){
     if(d==main)
     {
         if(c==call)

              call(""+num);
     }

 }


 public void pauseApp()
 {
 // No implementation required
 }



/*


 * /
 */


/**
 * From MIDlet. Called to signal the MIDlet to terminate.
 *
* @param unconditional
 * whether the MIDlet has to be unconditionally terminated
 */
 public void destroyApp(boolean unconditional)
 {
 // No implementation required
 }

/**
 * From CommandListener. Called by the system to indicate that a command has
 * been invoked on a particular displayable.
 *
* @param command
 * the command that was invoked
 * @param displayable
 * the displayable where the command was invoked
 */



       }

私のログトレース

Copying 1 file to C:\Users\ELHADI\Documents\NetBeansProjects\DiallNumber2\dist\nbrun5217990045006831680
Copying 1 file to C:\Users\ELHADI\Documents\NetBeansProjects\DiallNumber2\dist\nbrun5217990045006831680
Jad URL for OTA execution: http://localhost:8082/servlet/org.netbeans.modules.mobility.project.jam.JAMServlet/C%3A/Users/ELHADI/Documents/NetBeansProjects/DiallNumber2/dist//DiallNumber2.jad
Starting emulator in execution mode
Installing suite from: http://127.0.0.1:49320/DiallNumber2.jad
[WARN] [rms     ] javacall_file_open: _wopen failed for: C:\Users\ELHADI\javame-sdk\3.0\work\0\appdb\_delete_notify.dat
4

1 に答える 1

1

私は問題を解決しました

import javax.microedition.io.ConnectionNotFoundException;
import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.CommandListener;
import javax.microedition.lcdui.Display;
import javax.microedition.lcdui.*;
import javax.microedition.lcdui.Displayable.*;
import javax.microedition.lcdui.Form.*;
 import javax.microedition.midlet.MIDlet;
 import java.io.IOException;
 import java.io.InputStreamReader;
 import javax.microedition.lcdui.*;
 import javax.microedition.midlet.MIDlet;

public class DiallNumber extends MIDlet  
 {




    private  Display display;
 private MIDlet midlet;


Form f = new form("f");






/**}
 * From MIDlet. Called when the MIDlet is started.
 */
 public void startApp()
 {


display = Display.getDisplay(this);
  display.setCurrent(f);
}










 public void pauseApp()
 {
 // No implementation required
 }



/*


 * /
 */


/**
 * From MIDlet. Called to signal the MIDlet to terminate.
 *
* @param unconditional
 * whether the MIDlet has to be unconditionally terminated
 */
 public void destroyApp(boolean unconditional)
 {
 // No implementation required
 }
   class form extends   Form  implements CommandListener

           {
           private  Command call;

            private TextField phoneField;
           private String n;
   public form(String title )
       {
       super(title);

       call =new Command("call",call.OK,0);
       this.phoneField =new TextField("number","",20,phoneField.PHONENUMBER);


   addCommand(call);
   append(this.phoneField);

   this.setCommandListener(this);
      }

        public void commandAction(Command c,Displayable  d)
       {

   if(c==call)
   {


   try
   {
       n=phoneField.getString().trim();
      platformRequest("tel:"+n);


   }
  catch(javax.microedition.io.ConnectionNotFoundException e)
  {e.printStackTrace();}
   }


   }

   }




       }
于 2012-12-02T12:56:52.833 に答える