- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
我正在使用下面的代码(尤其是 pushMessage
方法)向用户显示一些通知:
public final class MyApplicationMessageFolder
{
public static final long MyFolderId = 0x1256789012F10123L;
private ApplicationMessageFolder folder_;
private ApplicationIndicator indicator_;
private MyReadableListImpl collection_;
public void pushMessage(String subject, String message)
{
try
{
if (collection_ == null)
{
collection_ = new MyReadableListImpl();
}
if (indicator_ == null)
{
registerFolderAndIndicator();
}
ApplicationMessage am = new MyApplicationMessage(message, subject);
collection_.addMessage(am);
folder_.fireElementAdded(am);
// Update indicator
int size = collection_.size();
indicator_.setValue(size);
indicator_.setVisible(size > 0);
}
catch (Exception e)
{
System.out.println(e.getMessage());
}
}
private void registerFolderAndIndicator()
{
// registration application folder and indicator
ApplicationMessageFolderRegistry amfr =
ApplicationMessageFolderRegistry.getInstance();
folder_ = amfr.getApplicationFolder(MyFolderId );
if (folder_ == null)
{
folder_ =
amfr.registerFolder(MyFolderId , "My Folder", collection_, true);
ApplicationIcon icon =
new ApplicationIcon(image_ = EncodedImage.getEncodedImageResource("my_icon.png"), true);
int status = ApplicationMessage.Status.INCOMING | ApplicationMessage.Status.UNOPENED;
amfr.registerMessageIcon(0, status, icon);
folder_.setSearchProperties(new ApplicationMessageSearchProperties(true));
folder_.addListener(
new ApplicationMessageFolderListener() {
public void actionPerformed(int action, ApplicationMessage[] messages,
ApplicationMessageFolder folder) {
if (action == ApplicationMessageFolderListener.MESSAGE_DELETED) {
for (int i = 0; i < messages.length; i++)
collection_.removeMessage(messages[i]);
indicator_.setValue(collection_.size());
indicator_.setVisible(collection_.size() > 0);
}
}
},
ApplicationMessageFolderListener.MESSAGE_DELETED |
ApplicationMessageFolderListener.MESSAGE_MARKED_OPENED |
ApplicationMessageFolderListener.MESSAGE_MARKED_UNOPENED,
ApplicationDescriptor.currentApplicationDescriptor());
ApplicationMenuItem[] menu = new ApplicationMenuItem[] {
new ApplicationMenuItem(0) {
public String toString() {
return "Go to application";
}
public Object run(Object context) {
return null;
}
}
};
amfr.registerMessageMenuItems(0, status, menu,
ApplicationDescriptor.currentApplicationDescriptor());
amfr.setBulkMarkOperationsSupport(0, status, true, false);
ApplicationIndicatorRegistry air = ApplicationIndicatorRegistry.getInstance();
air.register(new ApplicationIcon(EncodedImage
.getEncodedImageResource("bar_icon_25.png")),
false, false);
indicator_ = air.getApplicationIndicator();
}
}
class MyApplicationMessage implements ApplicationMessage
{
private String message_;
private String subject_;
private long timestamp_;
public MyApplicationMessage(String message, String subject) {
message_ = message;
subject_ = subject;
timestamp_ = new Date().getTime();
}
public String getContact() {
return "HelloWorld";
}
public Object getCookie(int cookieId) {
return null;
}
public Object getPreviewPicture() {
return image_;
}
public String getPreviewText() {
return message_;
}
public int getStatus() {
return ApplicationMessage.Status.UNOPENED;
}
public String getSubject() {
return subject_;
}
public long getTimestamp() {
return timestamp_;
}
public int getType() {
return 0x01;
}
}
private class MyReadableListImpl implements ReadableList {
private final Vector messages;
MyReadableListImpl() {
messages = new Vector();
}
public Object getAt(final int index) {
return messages.elementAt(index);
}
public int getAt(final int index, final int count,
final Object[] elements, final int destIndex) {
return 0;
}
public int getIndex(final Object element) {
return messages.indexOf(element);
}
public int size() {
return messages.size();
}
void addMessage(final ApplicationMessage message) {
messages.addElement(message);
}
void removeMessage(final ApplicationMessage message) {
messages.removeElement(message);
}
}
}
我可以在我的消息文件夹中看到我的消息,但我仍然无法在通知栏中看到它们
谁能解释为什么我看到空的通知栏?
谢谢
最佳答案
要在通知下拉列表中查看消息,需要使用:
ApplicationFolderIntegrationConfig config = new
ApplicationFolderIntegrationConfig(true, true,
ApplicationDescriptor.currentApplicationDescriptor());
folder_ = amfr.registerFolder(MyFolderId , "My Folder", collection_, config);
改为:
folder_ = amfr.registerFolder(MyFolderId , "My Folder", collection_, true);
关于java - 黑莓 - "you currently have no new notifications",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14952223/
我想创建后台应用程序,它将监听哪些应用程序已启动以及哪些应用程序移至前台。 请回复 如果问题不清楚会再次解释。 谢谢 最佳答案 这是你可以做的: 使用 ApplicationManager.getFo
下午好。 我开始用 java 和 blackberry 编程。 我正在开发一个带有三个窗口的应用程序,我将显示有关设备的基本信息,这些窗口已经完成并可以工作。 我需要创建一个在后台运行的进程,这个进程
如何翻转 Bitmap上下翻转? (我需要这个来在另一个程序中加载 OpenGL 纹理)。 这是我失败的尝试: stripe.png(由 Pitr@OpenClipart 提供): 翻转.java:
从 Internet 上可用于签署 BB 应用程序的内容来看,我可以猜测我们只需要用于签署应用程序的 .cod 文件,而不需要源代码。 有人可以确认这一点吗? 最佳答案 编译代码时会自动生成 .cod
我想访问闹钟。在我的应用程序中,我已成功访问日历并设置了约会,但我如何访问闹钟。请帮我。以下是我的代码 public class Alarm { private Event event;
作为应用程序的一部分,我们将在设备上的“file:///store/home/user/”位置创建一个文件 myApp.cfg。设备上的加密已启用。因此,myApp.cfg 被重命名为 myApp.c
我需要制作一个包含可点击号码的标签,这样当用户点击标签时,就会调用电话号码(或向用户显示调用电话的选项)。当我现在点击标签时,我只得到一个工具提示类型的菜单,其中包含复制数字的选项... privat
我有兴趣在我的 BlackBerry 应用程序中添加一个可拖动的 slider 。 我想知道 BlackBerry API 中是否有类似的东西,或者是否有人做过类似的东西! 最佳答案 有一个Gauge
最初开发黑莓应用的时候,并没有太在意能够支持多种屏幕分辨率。所以,我最终得到了在 320*240 分辨率下运行良好但在其他屏幕上完全困惑的代码。 我该如何解决这个问题?或者一般来说,如果不为每个资源构
我创建了一个这样的静态函数。 public static Bitmap Bitmap(String path) { Bitmap bitmap = Bitmap .ge
我需要 BlackBerry 本地化方面的帮助。我在 http://na.blackberry.com/eng/developers/resources/developer_labs.jsp#tab_
我创建了一个 RichTextField 我想让它只允许整数值。我怎样才能做到这一点? 最佳答案 你可以尝试这样的事情: public class MyRichTextField extends Ri
在 BlackBerry 平台中,我想知道是否可以/如何执行以下操作: 检索通话记录(我对来电记录特别感兴趣); 删除特定的通话记录; 最佳答案 要检索电话日志,请查看 PhoneCallLog cl
我想知道我们是否可以调整图像大小。假设我们要在黑莓屏幕上绘制一个实际尺寸为200x200且尺寸为100 x 100的图像。 谢谢 最佳答案 只是一种选择: BlackBerry - draw imag
黑莓 JDE 不包括 java.util.ArrayList ,即使它知道 java.util ?那是怎么回事? BB 有对应的类(class)吗?我不想使用数组,真的,因为我要处理的对象数量未知。为
我想使用 graphics.drawLine 方法在 drawListRow 中的黑莓 Listfield 中添加一个分隔符,但下面根本没有绘制线是我正在使用的来源 drawListRow(ListF
我正在为Blackberry设备开发一个应用程序。这个程序包含一个数据库。由于该API是在最新的API版本上提供的,因此我决定使用SQLite。 我遵循了随处都可以找到的所有示例,但是无论发生什么情况
我已将 Blackberry 4.6.0 应用程序移植到 4.7.0 上的 Storm。除了我试图控制的触摸事件之外,一切都运行良好。我在下面的方法中捕获触摸事件,它按预期执行,但问题是在我的 tou
我正在为 BB 开发一个项目。该应用程序与网络一起工作,并通过 HTTP 发送/接收数据。现在我使用队列和队列管理器。管理器从一个后台线程开始,并在 while (true) 循环中工作,检查队列中是
我想在黑莓中合并两个图像。一张图像是大图像,另一张图像是小图像。小图像的位置将由开发人员定义。有哪些可能的方法? 最佳答案 您可以使用 Graphics 类以不同的偏移量在其上绘制多个位图。查看Gra
我是一名优秀的程序员,十分优秀!