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
jgobert
Posts: 22
Registered: ‎08-22-2012
My Device: Bold 9900
My Carrier: Verizon Wireless

Re: App crashing when accessing email attachment...

I package the application, publish it on my BES and then push it to my test device.  Its the long way around but I'm trying to keep it consistent with how it will be done in production just in case any odd issues pop up.  I did have some weird issues with my handheld last night after trying to debug the app on the device.  I'm running a factory reset on my device now just to eliminate any potential issues... it is almost done coming back up.  The enterprise activation shouldn't take more than 15 - 20 mins an I'll push the app and test again as soon as that's done.

Please use plain text.
Contributor
jgobert
Posts: 22
Registered: ‎08-22-2012
My Device: Bold 9900
My Carrier: Verizon Wireless

Re: App crashing when accessing email attachment...

Ok I'm totally doing a MAJOR happy dance right now!! 

 

Following the factory reset, I ran the enterprise activation and then re-assigned the software configuration in the BES.  Once everything finished and I let the phone reboot I ran a test and the app was able to receive the email, process the attachment and is now showing the data in the GUI.  Major achievement!!

 

I now need to fully vet out every piece of functionality in the app to make sure everything works AND I need to understand a bit better from you guys where I need to add the code to mark the messages as read and then delete them after processing.  That's a pretty important part of the deal with this app to prevent it from re-reading old messages and such.

 

Can you advise on where I should put those statements?  and should they be written the same as those I commented out or is there a different way to write the statements?

 

Thank you all so very, very much for your help!!!!

Please use plain text.
Administrator
MSohm
Posts: 14,528
Registered: ‎07-09-2008
My Device: BlackBerry Z30, BlackBerry PlayBook
My Carrier: Bell

Re: App crashing when accessing email attachment...

Congrats!

 

Those lines should be moved into the appropriate part of your GlobalEventListener (align the ID numbers).  Note that to save looking up the message again in the listener you could store a copy of the message in the RuntimeStore for your main application to read (recommended) or pass it along in the global event (less efficient).  Just remember to delete the message from the RuntimeStore when you are done with it.

 

Here are the docs on RuntimeStore.  Let us know if you have any questions about using it.

 

https://developer.blackberry.com/java/documentation/nonpersistentstore_1981765_11.html

Mark Sohm
BlackBerry Development Advisor

Please refrain from posting new questions in solved threads.
Problem solved? Click the Accept As Solution button.
Found a bug? Report it using Issue Tracker
Please use plain text.
Developer
peter_strange
Posts: 19,603
Registered: ‎07-14-2008
My Device: Not Specified

Re: App crashing when accessing email attachment...

Congrats also!

 

Just one thing, I am going to disagree with Mark here.

 

"you could store a copy of the message in the RuntimeStore...... "

 

Pass the message with your global event.  Otherwise you will run into trouble when you get two messages arriving at once.  Since you process the messages immediately the overhead is not significant, certainly to my mind not enough to justify writing some synchronization processing in RuntimeStore.  . 

Please use plain text.
Contributor
jgobert
Posts: 22
Registered: ‎08-22-2012
My Device: Bold 9900
My Carrier: Verizon Wireless

Re: App crashing when accessing email attachment...

I definitely need to keep it as simple as possible.  At this point I've been able to send data to the app from the server side, work with the data in the UI, and then submit the data back to the server.  So everything appears to be working.  I just need to be able to delete the messages now.

 

Given the code I've posted, and knowing that I had to comment out the two lines in the IncomingMail.java code, what's the easiest way to add them back in without being too complex?  Do I add them into the PrecisionMessage.java code?  If so, how do I write it in?  Here's what changed in IncomingMessage.java:

 

        if (messageFolder.getType() == Folder.INBOX && message.getSubject() != null && message.getSubject().trim().equals( "PrecisionMessage {8E730E0B-F94C-4e88-858C-20910B31C4C3}"))
        {
            System.out.println("Received Precision Message!!!");
            // [DNT] 09/26/09 - Item#1.5
            //message.setFlags(Message.Flag.OPENED);
            //message.setFlags(Message.Flag.OPENED | Message.Flag.DELETED);
            //messageFolder.deleteMessage(message);

            ApplicationManager.getApplicationManager().postGlobalEvent(0x5c8e492bc9269b0cL, 0, 0, message, null);  // ParseMessage
        }

Please use plain text.
Administrator
MSohm
Posts: 14,528
Registered: ‎07-09-2008
My Device: BlackBerry Z30, BlackBerry PlayBook
My Carrier: Bell

Re: App crashing when accessing email attachment...

You have the right idea here:

 

ApplicationManager.getApplicationManager().postGlobalEvent(0x5c8e492bc9269b0cL, 0, 0, message, null);

 

Now find the GlobalEventListener method and locate where message 0x5c8e492bc9269b0cL is being processed and add these lines:

 

message.setFlags(Message.Flag.OPENED);

message.getFolder().deleteMessage(message);

Mark Sohm
BlackBerry Development Advisor

Please refrain from posting new questions in solved threads.
Problem solved? Click the Accept As Solution button.
Found a bug? Report it using Issue Tracker
Please use plain text.
Contributor
jgobert
Posts: 22
Registered: ‎08-22-2012
My Device: Bold 9900
My Carrier: Verizon Wireless

Re: App crashing when accessing email attachment...

Ok... In the PrecisionCollector.java code I found where (I think) you're talking about but I want to confirm.

 

To me it looks like the message is being passed to PrecisionMessage.java in the second function "public void ProcessPrecisionMsg(boolean force)" in the else if block.  A new thread is spawned and the email message is passed along.  Given that, do I put the two statements you gave me following the PrecisionMsgThread.start(); line or do I write them into the PrecisionMessage.java code that's being kicked off here?  I'm used to VB where the code processing will eventually come back to this part once PrecisionMessage finishes whatever it's doing but that may not be accurate for this type of programming...?

 

    public void eventOccurred( long guid, int data0, int data1, Object object0, Object object1)
    {
        if (guid == 0x5c8e492bc9269b0cL)
        {
            Message EmailMsg = (Message)object0;

            EventLogger.logEvent(0x3401882cc7a5a956L, "Received Precision Message Global Event PrecisionCollector.eventOccured()".getBytes(), EventLogger.DEBUG_INFO);
            PrecisionMsgVector.addElement(EmailMsg);
            ProcessPrecisionMsg(false);
        }
    }

    public void ProcessPrecisionMsg(boolean force)
    {
        if(PrecisionMsgVector.isEmpty())
        {
            PrecisionMsgThread = null;
            return;
        }
        else if(force || PrecisionMsgThread == null || !PrecisionMsgThread.isAlive())
        {
            Message EmailMsg = ((Message)PrecisionMsgVector.firstElement());
            PrecisionMsgVector.removeElement(EmailMsg);
                   
            PrecisionMsgThread = new Thread(new PrecisionMessage(EmailMsg, this));
            PrecisionMsgThread.setPriority(Thread.MIN_PRIORITY);
            PrecisionMsgThread.start();
        }
    }

 

Please use plain text.
Developer
peter_strange
Posts: 19,603
Registered: ‎07-14-2008
My Device: Not Specified

Re: App crashing when accessing email attachment...

I looked at this code before, and to be frank, it is kind of strange.  Rather than running one Thread to process all the entries in the Vector, it starts a new Thread to process each entry.  May be the coder was worried about some 'hangover' for each Thread?   

 

Assuming you don't want to change this, then you have two choices.

 

1) Either do it before you before your code might start to process the message, i,e, before this statement:

PrecisionMsgVector.addElement(EmailMsg);

This will replicate what you were doing before in the listener, because the listener used to do this.

2) Do it in your PrecisionMessage run processing. 

 

But, in fact the delete is already done in your PrecisionMessage code - it is the last thing.  And there is little point marking an email as opened if you have deleted it.  So the changes you have made so far may well be enough. Can you test to see that the emails are deleted?

Please use plain text.
Contributor
jgobert
Posts: 22
Registered: ‎08-22-2012
My Device: Bold 9900
My Carrier: Verizon Wireless

Re: App crashing when accessing email attachment...

The delete in the PrecisionMessage code was commented out per an earlier suggestion. I never uncommented it. I just put those lines back in and repackaged. Just waiting on the push install to finish up and I'll test and post back. BRB.
Please use plain text.
Contributor
jgobert
Posts: 22
Registered: ‎08-22-2012
My Device: Bold 9900
My Carrier: Verizon Wireless

Re: App crashing when accessing email attachment...

Sweet!!!  Un-commenting those lines took care of the message deletions and everything still works as it should.  Looks like we're in business!

 

FYI... no worries on the code oddity comments... The app was worked on over a few years by several different coders... we got no documentation on it and there isn't much commenting to be found. It was a 3rd party company who was contracted to develop this for us but yeah... Hopefully as time goes on I can really put time into learning what I need to on Blackberry dev and then get it all cleaned up.

 

Guys, really... I have no way of expressing how much I truly appreciate your time, help and patience.  I wish I could take all of you who've helped out for an awesome dinner.  If there's ever anything I can do to return the favor please don't ever hesitate.

 

Thank you!!!

Please use plain text.