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
Contributor
Posts: 20
Registered: ‎01-20-2010
My Device: none
My Carrier: none
Accepted Solution

Problem with Transport

[ Edited ]

Hello gurus.

I have run into a little trouble with my application and I would really appreciate it if someone could lend a helping hand.

I have an application that needs to monitor incoming PIN messages and based on the subject take certain actions. The actions also vary depending on which page of the GUI is displayed if any at all. Here is the setup:

 

SECURESCREEN  is the main entrance and extends UiApplication.

PinListener is the background app which uses an alternate entry point.

 

 At a certain point users will need to exchange certain information in order to create an association between each other.  User “A” sends a request by pressing on a button on the UI. The message gets sent successfully with the appropriate subject . User B’s  listener in PinListener (background app) captures the event :

 

if (messageFolder.getType() == Folder.INBOX && orginalMessage.getSubject().startsWith("ACM$"))
   {
      if (orginalMessage.getSubject().equals(TheSbj1)) //received request
         {        
            try {
                    HandShake(0,new String(Base64InputStream.decode(orginalMessage.getBodyText())), null, orginalMessage);
                 } catch (IOException e1) {                    
                    orginalMessage.getFolder().deleteMessage(e.getMessage());                    
                    }
          }
     }

 

 

Here is the code of the HandShake function (in PinListener, the background app):

 

private void HandShake(final int Type, final String UID, final byte[] Tranz, Message M)
{
   if (MYSECURESCREEN != null )
   {      
    //Grab the lock for the running SECURESCREEN.
    MYSECURESCREEN.invokeAndWait(new Runnable()
    {
      public void run()
      {
        //Check if the peer is on the association page
        if (SECURESCREEN.getUiApplication().getActiveScreen().toString().equals("AddContactScreen"))
        {
          String MCode = MYSECURESCREEN.VPN(UID, Tranz,Type);
          try {
                 Message msg = new Message();
                 PINAddress recipients[] = new PINAddress[1];
                 recipients[0] = new PINAddress("2100000A", "TEST");
                 msg.setSubject(TheSbj2);
                 msg.setContent(
MCode);
                 Transport.send(msg);


                } catch (MessagingException e) {
                   e.printStackTrace();                            
                    }
           }
         }
        });

   }

}

 

Everything is going well untill the Transport.send(msg) gets called and the application freezes. I tried sending the message from the function VPN in  SECURESCREEN, abviously the same thing happens (application freezes). Does any one have any idea why this is happenning.

 

Thank you in advance

Highlighted
Developer
Posts: 1,055
Registered: ‎01-25-2009
My Device: BlackBerry Bold 9650/BlackBerry Torch 9800

Re: Problem with Transport

Why are you doing an invokeAndWait?

 

It doesn't seem like you need to interact with the screen at the point that you're running that function so why do you need a lock?

 

Just wondering.

Jerome Carty - Follow jcarty on Twitter@jcarty | #webworks-dev / #BlackberryDev on irc.freenode.net | My Apps
Click "Accept as Solution" if post solved your original issue.. Give like/thumbs up if you feel post is helpful
Contributor
Posts: 20
Registered: ‎01-20-2010
My Device: none
My Carrier: none

Re: Problem with Transport

[ Edited ]

Hi Jerome,

 

Thank you for the reply. Actually I do need to use the  MYSECURESCREEN.invokeAndWait(new Runnable() because of the way the association between the users is made. That is, user "A" has to be viewing the "association page" and user "B" has to also be on the "AddContactScreen" screen on his blackberry. 

Basicaly, the first condition is receiving a message and checking its subject. After this, it is checking if the user is on the required page (SECURESCREEN.getUiApplication().getActiveScreen() .toString().equals("AddContactScreen")).  

When these conditions are satisfied the method "VPN" in SECURESCREEN calculates the required keys, informs the user that an association request was captured and fills in the required label fields. Finally the method returns a base 64 encoded byte to be set as the content of the PIN message.

Contributor
Posts: 20
Registered: ‎01-20-2010
My Device: none
My Carrier: none

Re: Problem with Transport

/bump

Contributor
Posts: 20
Registered: ‎01-20-2010
My Device: none
My Carrier: none

Re: Problem with Transport

Ok guys, I changed the InvokeAndWait to InvokeLater and it works.