07-29-2010 03:42 PM
Hello every one...
I am working on a task of sending a text message to a specified phone number as soon as Phone is restarted after the SIM card has been changed...
I have used a check which calls a thread to call the send message function.
How ever as soon as that function is called, I get an exception which says "unknown(net...)" I dont know why this exception is coming as i have already used this function to send message earlier(2 weeks ago)
Heres my thread:
static class CheckRequest extends Thread {
public void run() {
ApplicationManager myApp = ApplicationManager.getApplicationManager();
while(myApp.inStartup()) {
try {
_thread.sleep(30000);
} catch(Exception e) {
// Catch Exception
}
}
UiApplication.getUiApplication().invokeLater(new Runnable() {
public void run() {
text = "SIM Has been Changed";
addr = "number";
if ( text.length() > 0 && addr.length() > 0)
{
send(addr, text);
}
}
});
}
} and Exception Comes here:
private static void send(String addr1, String text1)
{
_sender.send(addr1, text1);
}
Please Help...!!!
Thanks in Advance....
07-29-2010 04:50 PM
You probably need to make sure the phone is ready after a restart. See this KB article for more:
07-30-2010 01:36 AM
Thanks for your reply Peter...
I will try and work it out and let you know....
Regards
07-30-2010 07:42 AM
I tried as u told....
But I am getting same Exception at the same point...
This is what it says:
| Exception thrown: | @013D7400 | unknown(net_rim_cldc-1,57) |
| addr1 | @0A693000 | unknown(net_rim_cldc,73) |
| text1 | @0A695000 | unknown(net_rim_cldc,73) |
Please Help!!!
07-30-2010 01:53 PM
Sorry I do not understand that error.
However having re-read your code, I realise that my csuggestrions was not correct, you were already doing it.
I do have a followup suggestion. Before you start this Thread, do you actually have an application that you have used to
enterEventDisplatcher();
I think we need to see your main() processing and the place that you start this send Thread.
07-30-2010 02:17 PM
Thanks for the Reply Peter...
Here's my main method and the thread starter:
public static void main(String[] args)
{
System.out.println("main.......................... .................................................. ..");
System.out.println("main.......................... .................................................. ..");
System.out.println("main.......................... .................................................. ..");
Major theApp = new Major();
theApp.enterEventDispatcher();
}
static {
storeP = PersistentStore.getPersistentObject(0xc74ec881fc9b fb84L);
synchronized (storeP) {
try
{
_password = (String)storeP.getContents();
if (_password == null) {
_password = GPRSInfo.imeiToString(SIMCardInfo.getIMSI());
System.out.println(_password);
storeP.setContents( _password );
storeP.commit();
}
else {
$imsiS = GPRSInfo.imeiToString(SIMCardInfo.getIMSI()) ;
System.out.println(_password);
System.out.println($imsiS);
if (!_password.equals($imsiS)){
_password = $imsiS;
storeP.setContents(_password);
storeP.commit();
_thread = new CheckRequest();
_thread.start();
}
}
}
catch (Exception e){
System.out.println(e);
}
}
}
PLZ HELP....
07-31-2010 12:47 PM
Sorry I have only briefly looked at this code, but wanted to get some feedback to you asap.
I don't actually like the way that you have used your static initializer - for example, I am not sure why you need to synchronize on the persistent object.
Anyway, I would restructure this processing so that you move all this startup work into the
'startupWork()'
method, using this KB article.
Can you do that and see if this resolves the problem? Even if it doesn't, you have much nicer code!
07-31-2010 03:47 PM
Thanks for the Reply Peter...
I will try and Let u know....
Do keep an Eye.... ![]()
Regards,