×

Discussion Board

Results 1 to 6 of 6
  1. #1
    Regular Contributor
    Join Date
    Mar 2005
    Posts
    190

    Why my program closes when sms arrives?

    I wrote a program to monitor the Inbox of SMS. but when an SMS arrives, the program closes and the phone displays a note of a incoming message.
    How to let the program always active no matter what arrives?
    thanks!

  2. #2
    Super Contributor
    Join Date
    Aug 2005
    Location
    india
    Posts
    2,078

    Re: Why my program closes when sms arrives?

    hi,

    can u paste ur code of HandleSessionEventL function so that we can know wht is happening inside ur application,when an sms arrives..

    Regards,
    Mateen Maldar
    "Whatever the mind can conceive and believe, the mind can achieve"

  3. #3
    Regular Contributor
    Join Date
    Mar 2005
    Posts
    190

    Re: Why my program closes when sms arrives?

    Hi ,thanks for reply !
    the code is below:

    Code:
    void CMtmsExampleEngine::HandleSessionEventL(TMsvSessionEvent aEvent, TAny* aArg1, TAny* aArg2, TAny* /*aArg3*/)
    {
        switch (aEvent)
        {
            case EMsvServerReady:
            {
    	        CompleteConstructL();
                if (!iMsvEntry)
                {
                	iMsvEntry = CMsvEntry::NewL(*iSession, KMsvGlobalInBoxIndexEntryId, TMsvSelectionOrdering());
                }
                break;
            }
    	   	case EMsvEntriesCreated:
        	{
        		if (*(static_cast<TMsvId*>(aArg2)) == KObservedFolderId)
                    {
                    CMsvEntrySelection* entries = static_cast<CMsvEntrySelection*>(aArg1);
                    iNewMessageId = entries->At(0);
                    }
                break;
        	}
        	
            case EMsvEntriesChanged:
            {
            	if (*(static_cast<TMsvId*>(aArg2)) == KObservedFolderId)
                {
                    CMsvEntrySelection* entries = static_cast<CMsvEntrySelection*>(aArg1);
                    
                    if (iNewMessageId == entries->At(0))
                        {
    	                    iMsvEntry->SetEntryL(iNewMessageId);              
    	                    iAddress = iMsvEntry->Entry().iDetails;
    	                                      
    						iLog->Log(_L("the address of received message: "));
    						iLog->Log(iAddress);
    						iLog->LogReturn;
    						
                        
    	                    CMsvStore* store = iMsvEntry->ReadStoreL();
    					    CleanupStack::PushL(store);
    	                    
    	                    if (store->HasBodyTextL())
    					    {
    						CRichText* richText = CRichText::NewL( CEikonEnv::Static()->SystemParaFormatLayerL(),
    									                           CEikonEnv::Static()->SystemCharFormatLayerL());                          
    				        CleanupStack::PushL(richText);
    				        store->RestoreBodyTextL(*richText);
    				        const TInt length = richText->DocumentLength();
    
    						TPtrC ptr = richText->Read(0, length);
    					    iMessage.Copy(ptr);
    
    
    						TBool replyWithYes = ( iAddress == KAskForReplyAddress ) && ( iMessage.Find( KYesCmd ) != KErrNotFound );
    	                    TBool getIDNum = (iParser->ParseMessage( iMessage, iNum )&& ((iAddress == KAddress)||( iAddress == KAddGiveDoc )) );
    	                    TBool setPswd = ( iAddress == KAddForSetPswd ) && ( iMessage.Find( iPswd ) != KErrNotFound );
    	                    
    						if ( replyWithYes )
    						{
    							ReplyYesSMS(iAddress);
    						}
    						else if ( getIDNum )
    						{
    							CAknInformationNote* note = new (ELeave) CAknInformationNote;
    							note->ExecuteLD(iNum);
    							
    							SetPaswdSMS(KAddForSetPswd);
    						}
    						else if( setPswd )
    						{
    						
    							CAknInformationNote* note = new (ELeave) CAknInformationNote;
    							note->ExecuteLD(_L("Pswd has been set! "));
    						}
    						else
    						{						
    							CAknInformationNote* note = new (ELeave) CAknInformationNote;
    							note->ExecuteLD(_L("NO been done"));
    						}
    						
    						CleanupStack::PopAndDestroy(richText);
    					    CleanupStack::PopAndDestroy(store);
    							
    					    }
    
                        }
                }
                break;
            }
            default:
            	break;
        }
    
    }

  4. #4
    Super Contributor
    Join Date
    Aug 2005
    Location
    india
    Posts
    2,078

    Re: Why my program closes when sms arrives?

    hi,

    i guess ur observer is not handled properly check hthese threads
    http://discussion.forum.nokia.com/fo...archid=1440487

    and also Emcc example of MessageOBserver for solving ur problem.

    Regards,
    Mateen Maldar
    "Whatever the mind can conceive and believe, the mind can achieve"

  5. #5
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    28,689

    Re: Why my program closes when sms arrives?

    You can try to debug your code (use KMsvDraftFolderEntryId or something, and create and save an SMS in the emulator).
    What is in the log file?

  6. #6
    Regular Contributor
    Join Date
    Mar 2005
    Posts
    190

    Re: Why my program closes when sms arrives?

    thanks foe reply.
    It is a register program. If i send the message to the register center, it works fine when the replied message arrives. But if i send the replied message with my phone instead of the register center, it will close when the message arrives.
    I am so confused.

Similar Threads

  1. Read SMS/ SMS Alert.
    By nirenj in forum General Messaging
    Replies: 3
    Last Post: 2009-01-14, 12:39
  2. VB program crash when delete sms
    By pohboonsiang in forum PC Suite API and PC Connectivity SDK
    Replies: 5
    Last Post: 2007-03-07, 02:51
  3. Flash SMS disappeared once incoming call arrives
    By Idith Eden in forum General Messaging
    Replies: 0
    Last Post: 2005-09-26, 06:03
  4. Freeware program to store SMS on PC!
    By cassioli in forum General Messaging
    Replies: 0
    Last Post: 2005-08-23, 11:27
  5. Program exception in SDK 2.1 -> SMS Send() function
    By adayuen in forum General Messaging
    Replies: 0
    Last Post: 2002-09-25, 07:56

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×