fa_te64
پنج شنبه 25 آذر 1389, 15:52 عصر
سلام
من برای دریافت پیام در برنامم کد ضمیمه رو نوشتم اما هرکار میکنم جواب نمیده!ممنون میشم اگه بررسی کنید مشکلش چیه،خیلی فوریه!
private void startReceive() {
if (mReceiver != null) {
return;
}
// Start receive thread
mReceiver = new Thread(this);
mReceiver.start();
}
private boolean mEndNow = false;
private MessageConnection conn = null;
public void run() {
Message msg = null;
String mPorti = "1234";
String msgReceived = null;
Status_Form FrmStatus;
int i = 0;
mEndNow = false;
/** Check for sms connection. */
try {
conn.close();
conn = null;
conn = (MessageConnection) Connector.open("sms://+98915….:" + mPorti);
conn.setMessageListener(this);
String[] connections;
connections = PushRegistry.listConnections(true);
if ((connections == null) || (connections.length == 0)) {
Alert t = new Alert("Waiting for Authentication Request");
//content.setString("Waiting for Authentication Request");
}
msg = conn.receive();
while ((msg != null) && (!mEndNow)) {
if (msg instanceof TextMessage) {
msgReceived = ((TextMessage) msg).getPayloadText();
Status_Form status = new Status_Form(msgReceived, rooti, "وضعیت ارسال ", this);
rooti.disp.setCurrent(status);
}
msg = conn.receive();
}
} catch (IOException e) {
// Normal exit when connection is closed
}
}
وقتی ارسال پیام صورت میگیره در خط بعد تابع startRecieve رو نوشتم.
من برای دریافت پیام در برنامم کد ضمیمه رو نوشتم اما هرکار میکنم جواب نمیده!ممنون میشم اگه بررسی کنید مشکلش چیه،خیلی فوریه!
private void startReceive() {
if (mReceiver != null) {
return;
}
// Start receive thread
mReceiver = new Thread(this);
mReceiver.start();
}
private boolean mEndNow = false;
private MessageConnection conn = null;
public void run() {
Message msg = null;
String mPorti = "1234";
String msgReceived = null;
Status_Form FrmStatus;
int i = 0;
mEndNow = false;
/** Check for sms connection. */
try {
conn.close();
conn = null;
conn = (MessageConnection) Connector.open("sms://+98915….:" + mPorti);
conn.setMessageListener(this);
String[] connections;
connections = PushRegistry.listConnections(true);
if ((connections == null) || (connections.length == 0)) {
Alert t = new Alert("Waiting for Authentication Request");
//content.setString("Waiting for Authentication Request");
}
msg = conn.receive();
while ((msg != null) && (!mEndNow)) {
if (msg instanceof TextMessage) {
msgReceived = ((TextMessage) msg).getPayloadText();
Status_Form status = new Status_Form(msgReceived, rooti, "وضعیت ارسال ", this);
rooti.disp.setCurrent(status);
}
msg = conn.receive();
}
} catch (IOException e) {
// Normal exit when connection is closed
}
}
وقتی ارسال پیام صورت میگیره در خط بعد تابع startRecieve رو نوشتم.