1
我正在開發一個適用於無線消息API(WMA)的j2me中的應用程序。該應用程序的任務是發送和2移動phone.When我運行在NetBeans模擬器,所以它工作正常,但在應用程序之間發送和接收短信,當我在諾基亞運行5200手機,我給手機這個異常:j2me中的SecurityException發送/接收SMS的WMA應用程序
Security java/lang/SecurituException Not allowed to open connection
的JAD我的應用程序的文件是:
MIDlet-1: Midlet, , hello.Midlet
MIDlet-Jar-Size: 36375
MIDlet-Jar-URL: SinaNetwork.jar
MIDlet-Name: SinaNetwork
MIDlet-Permissions: javax.microedition.io.Connector.sms, javax.wireless.messaging.sms.receive, javax.wireless.messaging.sms.send
MIDlet-Vendor: Vendor
MIDlet-Version: 1.0
MicroEdition-Configuration: CLDC-1.0
MicroEdition-Profile: MIDP-2.0
應用程序代碼也:
Thread receive=new Thread(new Runnable() {
MessageConnection ms;
public void run() {
// System.out.print("*****************SALAM*******");
try {
ms= (MessageConnection) Connector.open("sms://:"+7000);
// System.out.println("Zoor mizanam Receive konam");
Date zaman=new Date();
long zamanTemp=zaman.getTime();
TextMessage tempmes=(TextMessage) ms.receive();
// System.out.print("SMS receive: "+tempmes.getPayloadText());
Midlet.messageReceived=true;
Midlet.ReceivedThatWeDontKnowIsRandom=tempmes.getPayloadText();
}
catch(SecurityException eds)
{
eds.printStackTrace();
// System.out.print("");
}
catch (IOException ex) {
ex.printStackTrace();
}
}
});
receive.start();
Thread sendmesThread=new Thread(new Runnable() {
public void run() {
try {
MessageConnection mc=(MessageConnection) Connector.open("sms://"+Midlet.smsPhoneNumber+":"+5000);
TextMessage tm=(TextMessage) mc.newMessage(MessageConnection.TEXT_MESSAGE);
// System.out.print("PNF : "+phoneNumberField.getString());
tm.setPayloadText(rd+"-"+phoneNumberField.getString());
mc.send(tm);
// System.out.print("message sent from client on port 5000");
mc.close();
}
catch (IOException ex) {
ex.printStackTrace();
}
}
});
sendmesThread.start();
我覺得現在的問題是,應用程序無法打開森迪連接ng或接收SMS,但我不知道爲什麼,因爲我在模擬器中沒有問題。
我試試這個代碼,但我也有這個代碼too.i幾乎相信問題是從打開連接線,但我不知道爲什麼有這個該死的問題 – CoderInNetwork
你的應用程序簽名?如果你得到SecurityException,那麼這可能是問題。 –
是的,我從這裏簽署了申請:www.j2start.com/p/sign-your-midlet.html ...我真的搜查整個網絡,但我沒有發現任何有用的東西。你有任何想法親? – CoderInNetwork