BlackBerry Forums Support Community

BlackBerry Forums Support Community (http://www.blackberryforums.com/)
-   Developer Forum (http://www.blackberryforums.com/developer-forum/)
-   -   seperating notification for voice SMS(voice mail) from text SMS.. (http://www.blackberryforums.com/developer-forum/220584-seperating-notification-voice-sms-voice-mail-text-sms.html)

anuj866 02-24-2010 11:26 PM

seperating notification for voice SMS(voice mail) from text SMS..
 
"
PHP Code:

"



public final class GUILessApp extends Application implements javax.wireless.messaging.MessageListener

        
        int flag=0;//just for the sake of diff. between msgs
        SMSParameters sp=new SMSParameters();
        
        int headerid;                                                                   //header of the SMS recieved
        int voiceid=SMSParameters.PROTOCOL_ID_VOICE;    //Header value for VOice SMS
         
        
        //public int getProtocolId(); returns the PROTOCOL_ID_VOICE; //REturns the SMS header ID (sms/voice)
         

        
         private BackGroundApp backGroundApp;
     public static void main(Stringxxx91;xxx93; args)
     {
          GUILessApp theApp = new GUILessApp();
         
          theApp.enterEventDispatcher();
     }

     public GUILessApp()
     {
          //Creates and starts a new BackGroundApp thread.

          backGroundApp = new BackGroundApp();
        // System.out.print("
reched bg grnd process");
          backGroundApp.start();
     }

     //The thread that will run in the background.
     private class BackGroundApp extends Thread
     {   
         
        
         
         boolean stopThread = false;
          public synchronized void stop()
          {
               stopThread = true;
          }

          public void run()
          {
               while (!stopThread)
               {
                   
                    System.out.println("
Application is running");
                    
                  

               }
          }
     }
     
     
     
     
     
     //Stop the thread on exit.
     protected void onExit()
     {
          backGroundApp.stop();
     }
     MessageConnection _mc1;
         Message m;
        public void notifyIncomingMessage(MessageConnection conn) 
        
        {
                //final MessageConnection _mc1;
                try {
                        _mc1 = (MessageConnection)Connector.open("
sms://:0");
                
} catch (IOException e) {
                        
// TODO Auto-generated catch block
                        
e.printStackTrace();
                }
                try {
                        
_mc1.setMessageListener(this);
                } catch (
IOException e) {
                        
// TODO Auto-generated catch block
                        
e.printStackTrace();
                }
                
Application.getApplication().invokeLater(new Runnable()
             {
                 public 
void run()
                 {
                
                                try {
                                        
_mc1.receive();
                                } catch (
InterruptedIOException e) {
                                        
// TODO Auto-generated catch block
                                        
e.printStackTrace();
                                } catch (
IOException e) {
                                        
// TODO Auto-generated catch block
                                        
e.printStackTrace();
                                }
                     
String address m.getAddress();
                     
String msg null;
                          if ( 
instanceof TextMessage )
                          {
                               
TextMessage tm = (TextMessage)m;
                               
msg tm.getPayloadText();
                          }
                          else if (
instanceof BinaryMessage) {
                               
StringBuffer buf = new StringBuffer();
                               
bytexxx91;xxx93; data = ((BinaryMessagem).getPayloadData();

                               
// convert Binary Data to Text
                               
                               
                               
try {
                                                        
msg = new String(data"UTF-8");
                                                } catch (
UnsupportedEncodingException e) {
                                                        
// TODO Auto-generated catch block
                                                        
e.printStackTrace();
                                                }
                          }
                          
                          else
                          {
                                  
System.out.println("Invalid Message Format");
                          }
                          if(  (
headerid=(sp.getProtocolId()))== voiceid)    
                          {
                                      
flag=1;
                                  
System.out.println("voice msg received" address);
                                  
UiApplication.getUiApplication().pushScreen(new msgscreen(flag));
                          }
                          else
                          {
                              
flag=0;
                          
System.out.println("Received SMS text from " address " : " msg);
                          
UiApplication.getUiApplication().pushScreen(new msgscreen(flag));
                                  
                          }
                    
                    
                }
              
             });
        
        
        }

        
                
    
                
                
                
                
                
                
                
        }


"

do you see any problems with this...let me know..


All times are GMT -5. The time now is 06:54 PM.

Powered by vBulletin® Version 3.6.12
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.