BlackBerry Forums Support Community               

Closed Thread
 
LinkBack Thread Tools
Old 02-24-2010, 11:26 PM   #1 (permalink)
Knows Where the Search Button Is
 
Join Date: Feb 2010
Model: 7100t
PIN: N/A
Carrier: VODAFONE
Posts: 18
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default seperating notification for voice SMS(voice mail) from text SMS..

Please Login to Remove!

"
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..
Offline  
Closed Thread


Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On





Copyright 2004-2014 BlackBerryForums.com.
The names RIM and BlackBerry are registered Trademarks of BlackBerry Inc.