Blackberry通知栏:如何替换消息预览窗口

Blackberry通知栏:如何替换消息预览窗口,blackberry,replace,message,preview,Blackberry,Replace,Message,Preview,您好,我正在尝试使用eclipse制作我的第一个blackberry应用程序,该应用程序的主要思想只是基于内部GPS显示当前位置。问题解决后,我必须在课程正文中声明ApplicationDescriptor。请。谢谢。更新后,如果您有解决方案,请。我不知道如何注册一个点击处理程序来从通知消息栏/消息文件夹启动我的应用程序 public final class DemoMessage implements ApplicationMessage { static final int DEMO_MES

您好,我正在尝试使用eclipse制作我的第一个blackberry应用程序,该应用程序的主要思想只是基于内部GPS显示当前位置。问题解决后,我必须在课程正文中声明ApplicationDescriptor。

请。谢谢。更新后,如果您有解决方案,请。我不知道如何注册一个点击处理程序来从通知消息栏/消息文件夹启动我的应用程序
public final class DemoMessage implements ApplicationMessage
{
static final int DEMO_MESSAGE_TYPE = 0x01;

private String _sender;
private String _subject;
private String _message;
private long _receivedTime;
private boolean _isNew;
private boolean _deleted;
private String _replyMessage;
private long _replyTime;
private EncodedImage _previewPicture;

public DemoMessage()
{
    _isNew = true;
}

DemoMessage(String sender, String subject, String message, long receivedTime)
{
    _sender = sender;
    _subject = subject;
    _message = message;
    _receivedTime = receivedTime;
    _isNew = true;
}

void reply(String message)
{
    markRead();
    _replyMessage = message;
    _replyTime = System.currentTimeMillis();
}

void messageDeleted()
{
    _isNew = false;
    _deleted = true;
}

void markAsNew()
{
    _isNew = true;
    _replyMessage = null;
}

void markRead()
{
    _isNew = false;
}

boolean isNew()
{
    return _isNew;
}

boolean hasReplied()
{
    return _replyMessage != null;
}

void setSender(String sender)
{
    _sender = sender;
}

void setSubject(String subject)
{
    _subject = subject;
}

void setReceivedTime(long receivedTime)
{
    _receivedTime = receivedTime;
}

void setMessage(String message)
{
    _message = message;
}

String getMessage()
{
    return _message;
}

void setPreviewPicture(EncodedImage image)
{
_previewPicture = image;
}

public String getContact()
{
return _sender;
}

public int getStatus()
{
    if(_isNew)
    {
        return MyApp.STATUS_NEW;
    }

    if(_deleted)
    {
        return MyApp.STATUS_DELETED;
    }

    if(_replyMessage != null)
    {
        return MyApp.STATUS_REPLIED;
    }

    return MyApp.STATUS_OPENED;
}

public String getSubject()
{
    if(_replyMessage != null)
    {
        return "Re: " + _subject;
    }
    else
    {
        return _subject;
    }
}

public long getTimestamp()
{
    return _receivedTime;
}

public int getType()
{
    return DEMO_MESSAGE_TYPE;
}

public String getPreviewText()
{
    if(_message == null)
    {
        return null;
    }

    StringBuffer buffer = new StringBuffer(_message);

    if(_replyMessage != null)
    {
        buffer.append(". You replied on ").append(new Date(_replyTime)).append(": ").append(_replyMessage);
    }

    return buffer.length() > 100 ? buffer.toString().substring(0, 100) + " ..." : buffer.toString();
}

public Object getCookie(int cookieId)
{
    return null;
}

public Object getPreviewPicture()
{
    return _previewPicture;
}
}
public final class DemoMessageScreen extends MainScreen
{
public DemoMessageScreen()
{       
    setTitle("Title");

    ReadableListImpl mylist= new ReadableListImpl();
    ApplicationMessageFolder folder = null;
    ApplicationFolderIntegrationConfig config = new ApplicationFolderIntegrationConfig(true, true, ApplicationDescriptor.currentApplicationDescriptor());

    if(ApplicationMessageFolderRegistry.getInstance().getApplicationFolder(0x33c7ce29883abe5fL)==null)
    {
         folder = ApplicationMessageFolderRegistry.getInstance().registerFolder(0x33c7ce29883abe5fL, "Test Folder", new ReadableListImpl(),config );
    }
    else
    {
         folder = ApplicationMessageFolderRegistry.getInstance().getApplicationFolder(0x33c7ce29883abe5fL);
    }

    DemoMessage msg = new DemoMessage("me@here.com", "Pizza Toppings","What would you like on your pizza?", System.currentTimeMillis());

    mylist.addMessage(msg);

    folder.fireElementAdded(msg,true);

    System.out.println("nr of messages"+folder.hasNewMessages());

    ApplicationIndicatorRegistry reg = ApplicationIndicatorRegistry.getInstance();

    EncodedImage image = EncodedImage.getEncodedImageResource("indicatorOn.png" );

    ApplicationIcon icon = new ApplicationIcon( image );

    ApplicationIndicator indicator = reg.register( icon, false, true);

    indicator.setNotificationState(true);

    ApplicationIndicator appIndicator = reg.getApplicationIndicator();

    appIndicator.setIcon(icon);

    appIndicator.setValue(appIndicator.getValue() + 1);

    //appIndicator.setNotificationState(true);

    appIndicator.setVisible(true);
}

public boolean onClose()
{
    close();
    return true;
}

static class ReadableListImpl implements ReadableList
{
    private Vector messages;

    ReadableListImpl()
    {
        messages = new Vector();
    }

    public Object getAt(int index)
    {
        return messages.elementAt(index);
    }

    public int getAt(int index, int count, Object[] elements, int destIndex)
    {
        return 0;
    }

    public int getIndex(Object element)
    {
        return messages.indexOf(element);
    }

    public int size()
    {
        return messages.size();
    }

   void addMessage(DemoMessage message)
    {
        messages.addElement(message);
    }

    void removeMessage(DemoMessage message)
    {
        messages.removeElement(message);
    }
}
}
public class MyApp extends UiApplication
{
static final int FLAG_REPLIED = 1 << 16;
static final int FLAG_DELETED = 1 << 17;
static final int BASE_STATUS = ApplicationMessage.Status.INCOMING;
static final int STATUS_NEW = BASE_STATUS | ApplicationMessage.Status.UNOPENED;
static final int STATUS_OPENED = BASE_STATUS | ApplicationMessage.Status.OPENED;
static final int STATUS_REPLIED = BASE_STATUS | ApplicationMessage.Status.OPENED | FLAG_REPLIED;
static final int STATUS_DELETED = BASE_STATUS | FLAG_DELETED;

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

public MyApp()
{   
        pushScreen(new DemoMessageScreen());
}
}