BlackBerry Forums Support Community
              

Closed Thread
 
Thread Tools
Old 02-25-2010, 12:26 AM   #1
anuj866
Knows Where the Search Button Is
 
Join Date: Feb 2010
Model: 7100t
PIN: N/A
Carrier: VODAFONE
Posts: 18
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



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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


Ram ROI Optical OMIS II Vision AutoCheck Metrology Measurement Inspection System picture

Ram ROI Optical OMIS II Vision AutoCheck Metrology Measurement Inspection System

$5700.00



ITENA Total C-Ram Self-adhesive Resin for metal,all ceramic, zirconium Dental picture

ITENA Total C-Ram Self-adhesive Resin for metal,all ceramic, zirconium Dental

$69.99



Ram Optical Istrumentation 000427 Optical Video Probe picture

Ram Optical Istrumentation 000427 Optical Video Probe

$220.00



Raspberry Pi Compute Module 4 CM4 2gb RAM 32GB eMMC WiFi CM4102032 picture

Raspberry Pi Compute Module 4 CM4 2gb RAM 32GB eMMC WiFi CM4102032

$50.00



Enerpac RC106 Hydraulic Ram Cylinder picture

Enerpac RC106 Hydraulic Ram Cylinder

$225.00



RAM-H4M1-03 -  IGNITION MODULE -  picture

RAM-H4M1-03 - IGNITION MODULE -

$160.00







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