在j2me中显示进程调用的警报

时间:2014-05-20 09:14:12

标签: multithreading background java-me alert

我正在为诺基亚e71开发一个应用程序。我希望在调用Locfinder.ex()函数之间显示一个时间间隔的警报,并返回位置值。我需要创建一个单独的线程吗? 我是Java的新手,所以仍然不清楚所有的概念。我在这里粘贴我的代码.Pleas提出一些建议。

   /*
   * To change this license header, choose License Headers in Project Properties.
   * To change this template file, choose Tools | Templates
   * and open the template in the editor.
   */

  package org.ets.screen;
  import javax.microedition.lcdui.Command;
  import javax.microedition.lcdui.CommandListener;
  import javax.microedition.lcdui.Displayable;
  import javax.microedition.lcdui.Form;
  import javax.microedition.lcdui.TextField;
  import org.ets.midlet.ETS_infozech;
  import org.ets.utils.Chacheck;
  import org.ets.utils.Constants;
  import org.ets.utils.Locfinder;
  import org.ets.utils.TextMessageSender;


  /**
  *
  * @author Deepshikha
  * Purpose:for Check_out form
  * Date:21-April-2014
  * 
  * Modified by:Deepshikha Date:-16-May-2014 Purpose:-to add geotagging
  */
  public class check_out extends Form implements CommandListener{

private TextField txtSapId;
private Command send, back;
String smsTxt;
String smsNumber = Constants.phone_Number;
TextMessageSender sendMessage;
ETS_infozech midlet;

public check_out(ETS_infozech midlet) {
    super("Check_out Details"); //for the constructor of Form class
    this.midlet = midlet;

    txtSapId = new TextField("SAP ID:", "", 15, TextField.ANY); // for SAP ID

    send = new Command("Send", Command.OK, 1);
    back = new Command("Back", Command.BACK, 2);

    sendMessage = new TextMessageSender(midlet);

    append("Please Enter Detail");
    append("");
    append(txtSapId);
    append("");
    addCommand(send);
    addCommand(back);
    setCommandListener(this);

}

 public void commandAction(Command c, Displayable d) {
    if (c == send) {
        String valSapId = txtSapId.getString();

        if (valSapId.length() <= 0) {
            midlet.showalert("Please enter SAP ID");
        }



        else {
             int a;
             a=Chacheck.check(valSapId);//to valiadmindate SAPId field
             if (a==1){


                 midlet.showalert("Remove White space from SAPID!!!");

             }
             else if(a==2){

                 midlet.showalert("Symbols in sapid textbox!!!");

             }
             else{

                 smsTxt = "FNX COUT " + "SAPID-" + valSapId ;


                String s=Locfinder.ex();
                if(s==null){
                    midlet.showConfirm(smsTxt);

                }

                else{
                smsTxt=smsTxt+s;
                System.out.println(smsNumber + " ******** " + smsTxt);
                sendMessage.sendTextMessage(Constants.phone_Number, smsTxt);// for sending message with required string and MSISDN no.

                }
                }        
        }
    } else if (c == back) {
        midlet.showMainMenu();
    }
}

}

1 个答案:

答案 0 :(得分:0)

你可以让Locfinder.ex()“同步”,在那个函数中,第一行应该是showProgressBar(),最后一行是destroyProgressBar()。就是这样。