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
Developer
Posts: 254
Registered: ‎03-15-2011
My Device: simulator
My Carrier: simulator

Re: PIN message problem when sending and receiving devices are the same

Avib and Mark thanks for the reply..

 

Avib.. I could not get the exact meaning of your advice. Could you please make me understand it?

------------------------------------------------------------------------------------------------
Click "Accept as Solution" if post was what you needed. Give kudos if you feel response is helpful.

Developer
Posts: 254
Registered: ‎03-15-2011
My Device: simulator
My Carrier: simulator

Re: FolderListener for PIN messages in OS 6

When I made the folderListener functionality as background process and the remaining functionality as foreground process, this problem is solved.

------------------------------------------------------------------------------------------------
Click "Accept as Solution" if post was what you needed. Give kudos if you feel response is helpful.

New Contributor
Posts: 6
Registered: ‎09-21-2011
My Device: Pearl 9100

Re: FolderListener for PIN messages in OS 6

[ Edited ]

are you getting the notification from the incoming PIN Message? event from the another sender (not device PIN itself)? cause as far as i try, it only give notification only from the device itself. may i look for ur code?, may be mine is wrong.

Thank you in advance..... ^^

Highlighted
Developer
Posts: 254
Registered: ‎03-15-2011
My Device: simulator
My Carrier: simulator

Re: FolderListener for PIN messages in OS 6

It works fine for me..

 

Check this out !!

 

public final class FirstFolderListenerApp implements FolderListener {

  private FirstFolderListenerGUI folderListenerGUI = null;
  public static final long RTSID_MY_APP = 0x7451402f595f81a5L;

  public FirstFolderListenerApp() 
  {
    try
    {
     Store store = Session.getDefaultInstance().getStore();
   	 Folder[] folders = store.list();
   	 System.out.println("Total folders in store root......"+folders.length);
   	 for( int foldercnt = 0; foldercnt <folders.length ; foldercnt++) {
   	    Folder f = folders[foldercnt];
   	    System.out.println("Root folder name......"+ f.getFullName() );
   	    recurse(f);
   	 }
    }
    catch (Exception e)
    {
      System.out.println(e.toString());
    }
  }
  
  public void recurse(Folder f)
	 {
	    System.out.println("Folder name :"+f.getType());
	    Folder[] subFolders = f.list();
	    if(subFolders != null && subFolders.length !=0 || subFolders.length >0){
	    	for (int fcnt = 0; fcnt < subFolders.length ; fcnt++)  {
		        recurse(subFolders[fcnt]);
		    }
	    }else{  
	    	System.out.println("Node folder name......"+ f.getFullName()+".....Sent...."+Folder.SENT+".....Outbox...."+Folder.OUTBOX );
	    if ( f.getType() != Folder.OUTBOX && f.getType() != Folder.SENT)   {
	    	System.out.println("Listener set here.....Folder name in listener clause.... :"+f.getType());
	        f.addFolderListener(this);
	    	}
	    }
	 }
  
  //Returns an instance of the running FolderListenerApp.
  public static FirstFolderListenerApp waitForSingleton()
  {
    //Ensure this is a singleton instance.

    //Open the RuntimeStore.
    RuntimeStore store = RuntimeStore.getRuntimeStore();
    //Obtain the reference of FolderListenerApp.
    Object obj = store.get(RTSID_MY_APP);

    //If obj is null, there is no current reference
    //to FolderListenerApp. Start a new instance
    // of FolderListenerApp if one is not running.
    if (obj == null)
    {
      //Store a reference to this instance in the RuntimeStore.
      store.put(RTSID_MY_APP, new FirstFolderListenerApp());

      return (FirstFolderListenerApp)store.get(RTSID_MY_APP);
    } else
    {
      return (FirstFolderListenerApp)obj;
    }
  }

  //Called when a new message is created.
  public void messagesAdded(final FolderEvent e)
  {
    //Get the message that fired the folder event.
    Message orginalMessage = e.getMessage();
    //Get the folder the message is in.
    Folder messageFolder = orginalMessage.getFolder();

    //Is the new message in the Inbox?
    if (messageFolder.getType() == Folder.INBOX) 
    {

      //Check if the FolderListenerGUI is running.
      if (folderListenerGUI != null)
      {

        //Grab the lock for the running FolderListenerGUI.
        folderListenerGUI.invokeAndWait(new Runnable() 
        {
          public void run() 
          {
            //Call the NewMailArrived method to update the 
            //screen with a notification.
            folderListenerGUI.NewMailArrived(e);
          }
        });
      }
    }
  }

  //Passes in reference to the FolderListenerGUI that is running.
  public void setFolderListenerGUI(FirstFolderListenerGUI folderGUI)
  {
    folderListenerGUI = folderGUI;
  }

  //Set the reference to the FolderListenerGUI to null
  //(when it is shut down).
  public void unsetFolderListenerGUI()
  {
    folderListenerGUI = null;
  }

  //Not used in this sample.
  public void messagesRemoved(FolderEvent e)
  {
  }
}

 

------------------------------------------------------------------------------------------------
Click "Accept as Solution" if post was what you needed. Give kudos if you feel response is helpful.

New Contributor
Posts: 6
Registered: ‎09-21-2011
My Device: Pearl 9100

FolderListener for PIN messages in OS 6

thank you... :-D