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
New Contributor
Posts: 7
Registered: ‎05-19-2011
My Device: Curve 8520 IOS 4.6.1
My Carrier: Telcel
Accepted Solution

Using Attachment Manager in Alternate Entry Point

[ Edited ]

Hi Everyone

 

Im currently building an app that will run on OS 4.5 I'm currently developing with the Eclipse plug-in.

What I'm trying to do is create a context menu for attachments using the Attachment Manager, and registering it via an Alternate Entry Point so it starts and registers only when the phone starts.

I've already read the official BB articles on both Creating a Custom Attachment Handler and Creating an Alternate Entry Point and I'm pretty sure I've followed the instructions correctly.

 

So here's my main method:

 

    public static void main(String[] args)
    {
        if(args != null && args.length >0 && args[0].equals("att")){
            try {
                AttachmentHandlerManager m = AttachmentHandlerManager.getInstance();
                m.addAttachmentHandler(new AttachmentHandlerEntryPoint());
            } catch (Exception e) {
                e.printStackTrace();
            }
        }else{
            MyApp theApp = new MyApp();       
            theApp.enterEventDispatcher();
        }
    }

 

And here's my AttachmentHandlerEntryPoint class:

 

import net.rim.blackberry.api.mail.AttachmentHandler;
import net.rim.blackberry.api.mail.Message;
import net.rim.blackberry.api.mail.SupportedAttachmentPart;
import net.rim.device.api.ui.component.Dialog;

public class AttachmentHandlerEntryPoint implements AttachmentHandler{
    
    String[] supportedFiles  = {"doc","docx","xls","xlsx","ppt","pptx","jpg","jpeg","gif","png","bmp","pdf","txt"};
    
    public String menuString() {
        return "My Attachment Handler";
    }
    
    public void run(Message m, SupportedAttachmentPart p) {
        Dialog.alert("Filename: " + p.getFilename());
    }

    public boolean supports(String contentType) {
        boolean val = false;
        
        for (int i = 0; i < supportedFiles.length; i++) {
            if (contentType.toLowerCase().indexOf(supportedFiles[i]) != -1)
                val = true;
        }
        return val;
    }
}

 

 

As I mentioned, I have already defined the Alternate Entry Point to send the "att" arg to the simulator.

THE PROBLEM is that when I start the simulator and go to the email browser, click on an attachment, but don't see the context menu that is supposed to be created with the AttachmentManager....

Don't reallly understand what's happening...

Your help would be very much appreciated. Thanks!

BlackBerry Development Advisor
Posts: 15,784
Registered: ‎07-09-2008
My Device: BlackBerry PRIV
My Carrier: Bell

Re: Using Attachment Manager in Alternate Entry Point

You cannot create an AttachmentHandler for file types that are natively supported by the BlackBerry Smartphone. This and alternative methods of handling attachments is described here:

Delivering attachment contents to a BlackBerry smartphone
http://supportforums.blackberry.com/t5/Java-Development/Delivering-attachment-contents-to-a-BlackBer...
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