Joke Collection Website - Blessing messages - J2ME watching SMS
J2ME watching SMS
Import java.io.ioexception;
Import javax.microedition.midlet. *;
Import javax.microedition.io. *;
Import javax.wireless.messaging. *;
Common class example extension MIDlet implementation MessageListener {
Message connection messconn
int total = 0;
Boolean completion;
//Initial test setup and execution.
public void startApp() {
Try {
//Get our receive port connection.
Messconn = (message connection)
connector . open(" SMS://:6222 ");
//Register the listener for inbound messages.
mess conn . setmessagelistener(this);
//Start the message reading thread.
done = false
New thread (new reader ()). start();
} catch (IOException e) {
//Handling startup errors
}
}
//Asynchronous callback for inbound messages.
Public void notifyIncomingMessage {
if (conn == messconn) {
total++;
}
}
//Required MIDlet method-Release the connection and
//Notifies the reader that the thread is terminated.
public void pauseApp() {
done = true
Try {
mess conn . close();
} catch (IOException e) {
//Handling error
}
}
//the required MIDlet method-shutdown.
// @param unconditional forced shutdown flag
Public void destroyApp (Boolean unconditional) (
done = true
Try {
mess conn . setmessagelistener(null);
mess conn . close();
} catch (IOException e) {
//Handle the closing error.
}
}
//isolate the blocking I/O on a separate thread, so call back.
//You can return immediately.
Class readers implement Runnable {
The run method performs the actual message reading.
Public invalid operation () {
And (! Done) {
Try {
message mess = mess conn . receive();
} catch (IOException ioe) {
//Handling read errors
}
}
}
}
}
- Previous article:How does Unicom query the service password of mobile phone through SMS?
- Next article:How to avoid food waste?
- Related articles
- How to find your own certificate in ideological education
- Baidu Wenxin announced that it is open to the whole society in one sentence, and there are also newly reconstructed AI native applications. What information is worthy of attention? Actual use experien
- I'm going to Pizza Hut to interview the waiter tomorrow afternoon. What would I ask? How long is the interview? Is it difficult to be hired?
- How to set the ringtone of Apple iphone 5s?
- How to get a dynamic password
- How to log in to 189 mailbox by mobile phone?
- Is it true that I saw the job of "recruiting SMS responders at 100 yuan a day" on the Internet?
- What is the reimbursement process for employee mutual aid insurance?
- How to partially copy and paste the SMS content of iPhone?
- On the ninth day of the ninth lunar month, we should do blessing activities for the elderly (such as telling stories and sending text messages) and write a 600-word sentiment about respecting the elde