BlackBerry Forums Support Community               

Closed Thread
 
LinkBack Thread Tools
Old 05-04-2009, 04:18 AM   #1 (permalink)
New Member
 
Join Date: Nov 2008
Model: 8310
PIN: N/A
Carrier: Developer
Posts: 2
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default Adding menu item in Email Attachment BB application

Please Login to Remove!

i m trying the following code to add menu item in attachment file view but unable to do tht :

/*
* My Attachment Viewer
*
*/

package com.samples.attachmentViewer;

import net.rim.blackberry.api.mail.*;
import net.rim.blackberry.api.mail.event.*;
import net.rim.device.api.system.*;

class MyViewer extends Application implements AttachmentHandler
{

public static void main(String args[])
{
MyViewer theApp = new MyViewer();
}

public MyViewer()
{
//Add this AttachmentHandler to the AttachmentHandlerManager
AttachmentHandlerManager m = AttachmentHandlerManager.getInstance();
m.addAttachmentHandler(this);
}

//Called when a new email message arrives to see if it is supported
//by this AttachmentHandler (this sample supports wml).
//If it is true then the menu item will be shown in the message screen.
public boolean supports(String contentType)
{

boolean val;

if (contentType.toLowerCase().indexOf("wml") != -1)
val = true;
else
val = false;

return val;
}

//Then menu item that will appear from the message screen
public String menuString()
{
return "View File";
}

//Runs when the user selects the above defined menu item
public void run(Message m, SupportedAttachmentPart p)
{
//Perform required processing on your attachment here.
//Get the attachment filename.
System.out.println("WML filename: " + p.getFilename());
//Get the attachment size.
System.out.println("Attachment size is: " + p.getSize());
//Get the contents of the attachment.
byte[] temp = (byte[])p.getContent();
String data = new String(temp);
System.out.println("Attachment Content: " + data);

}
}

Can anybody tell me where the problem is. I m using JDK 4.5 and device software version 4.5. Kindly reply as soon as possible. i also have try to made the application System module and Autorun at start up.
Please ASAP
Regards,
Preeti
Offline  




Copyright 2004-2016 BlackBerryForums.com.
The names RIM and BlackBerry are registered Trademarks of BlackBerry Inc.