Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
Highlighted
Developer
Posts: 75
Registered: ‎07-21-2009
My Device: Not Specified

Message not sending

[ Edited ]

Hi,

         I cann't send the sms after reboot the phone.below is my code.is there timer problem.plz reply

 

//after reboot i call this funtion in main

 timer = new Timer();			 

 timer.scheduleAtFixedRate(new TimertoSendforSms(),25000,25000);



 private class TimertoSendforSms extends TimerTask
	    {

		    public synchronized void run()   
		    {
		    		
				
			    String IMSI = null; 
			    try 
			    {

				   IMSI=GPRSInfo.imeiToString(SIMCardInfo.getIMSI());
			    }
			    catch (SIMCardException e) 
			    {

			    }                  

			 
				timer.cancel();
				timer=null;
			   
			    SimchangedThread _simchaged = new SimchangedThread();
			    _simchaged.SendMessage(IMSI);
			    _simchaged.start();        	
			        	 

		   }  

	    }
	    
public class SimchangedThread extends Thread
{
        
    String MessageTosend;
    public void SendMessage(String Message)
    {
            MessageTosend=Message;
    }
    
    public void run() 
    {
          
          String address = "sms://"; 
      
  
          try 
          {
              
              smsconn = (MessageConnection)Connector.open(address);    
                              
	      String text = (String)attendees.elementAt(i);

	      TextMessage txtmessage =
		  (TextMessage)smsconn.newMessage(MessageConnection.TEXT_MESSAGE , "//" + text);
	      txtmessage.setPayloadText(MessageTosend);
	      smsconn.send(txtmessage);
	                              
       	      
                 
          } 
          catch (Throwable t)
          {
              System.out.println("Send caught: ");
              t.printStackTrace();
          }
  
          if (smsconn != null)
          {
              try
              {
                  smsconn.close();
              }
              catch (IOException ioe)
              {
                  System.out.println("Closing connection caught: ");
                  ioe.printStackTrace();
              }
              
             
            
          }
          
      }      
} 	    
	

 

 

 

Thanks,

sunil

Developer
Posts: 148
Registered: ‎11-16-2009
My Device: Not Specified

Re: Message not sending

[ Edited ]

Hi,

You set the application to auto-start ? 

If yes, maybe the sms transport is not ready  when you try to send the sms.  (After reboot it would good to log into a file and then you can see where stop your application, or what exception(s) are throw)