您好我正在嘗試使用eclipse製作我的第一個黑莓應用程序,該應用程序的主要想法是僅基於內部GPS顯示當前位置LatLong < <跳過此部分。黑莓通知欄:如何更換消息預覽窗口
現在的問題是我一直在尋找關於如何更換「消息預覽」窗口將近兩個星期,如果點擊 自定義消息在這裏出現的是我的代碼
類DemoMessage
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;
}
}
類DemoMessageScreen
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("[email protected]", "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);
}
}
}
和Class MyApp的
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());
}
}
代碼沒問題,我可以在主屏幕和消息文件夾中看到通知,但是如果點擊它會調用「消息預覽」窗口,我不知道如何註冊點擊處理程序以從通知消息啓動我的應用程序酒吧和消息文件夾,如何做到這一點?在此先感謝
請[請參閱此鏈接以瞭解如何在此類問題中發佈代碼](http://sscce.org/)。謝謝。 – Nate 2013-03-15 09:20:11
發佈更新,如果你有解決方案,請.. – Adrian 2013-03-15 09:52:19
我不知道如何註冊點擊處理程序從通知消息欄/消息文件夾 – Adrian 2013-03-15 12:12:44