【问题标题】:Add a notification icon at the status bar in BlackBerry JDE 4.5.0在 BlackBerry JDE 4.5.0 的状态栏中添加通知图标
【发布时间】:2010-12-14 12:53:10
【问题描述】:

我正在BlackBerry JDE 4.5 中编写一个Java 应用程序,它将在启动时开始监听某些事件。我想在状态栏显示一个小图标。

我知道它在 BlackBerry API 集的 4.6.0 版中支持 ApplicationIcon、ApplicationIndicator 和 ApplicationIndicatorRegistry 类,但 BlackBerry JDE 4.5.0 API 集中有哪些类?

更新

我认为对 4.5.0 有一些支持,因为我正在使用带有 OS v4.5.0.81 的 Blackberry Pearl 8100,它会在状态栏中显示任何传入消息或呼叫的通知图标。

我制作了 Alternale 入口点和主 CLDC 应用程序,如下文所示,

How To - Setup an alternate entry point for my application

我有一篇文章,

How to - Make a running UI application go to the background and resume in the foreground

其中说

无论应用程序是否正在运行,备用条目都将使用传入的参数调用 main 方法。

但在我的情况下,当应用程序在后台运行时单击 appIcon 时 main() 没有被调用。

它只更新之前在备用入口点中设置的 appIcon 和 appName。

因此,如果在单击 updatedIcon 时未调用 main(),我将无法获得控件的去向?

有人对这个问题有任何想法吗?


我更新了 appIcon 和 appName。

现在我想要的是“当单击 updatedIcon 时,应打开一个特定屏幕,当用户返回主菜单时,应用程序应获得其原始图标、应用程序名称,并且当单击时,流程应通过 main()原始应用图标”

我在想,当我点击更新的 appIcon 时,控件会转到 main(),但它不会调用 main(),而是说,

Starting AppName
AppName already running

& 直接进入第一个屏幕。当我回到主菜单时,应用程序已更新图标和名称

那么如何获得呢?

【问题讨论】:

    标签: user-interface blackberry notifications integration rim-4.5


    【解决方案1】:

    很遗憾,这是不可能的。您可以做的是更新应用程序图标。

    还有其他通知方式:
    Notification Service for Blackberry OS 4.5 application

    更新应用程序图标

    alt text http://img211.imageshack.us/img211/4527/icoupdate1.jpgalt text http://img697.imageshack.us/img697/3981/icon.jpgalt text http://img687.imageshack.us/img687/256/iconactive.jpgalt text http://img130.imageshack.us/img130/3277/icoupdate2.jpgalt text http://img691.imageshack.us/img691/6459/icoupdate3.jpg
    后台运行应用:

    public class NotifIconSrvc extends Application {
    
     private int mCount = 0;
     private int mSize = 0;
    
     public NotifIconSrvc() {
      Timer timer = new Timer();
      timer.schedule(sendEventTask, 1000, 3000);
     }
    
     TimerTask sendEventTask = new TimerTask() {
    
      public void run() {
       // Post the GlobalEvent.
       // Long = ci.samples.45.notificon
       ApplicationManager.getApplicationManager().postGlobalEvent(
         0x5a9f7caa171ab7b8L, mCount++, mSize++);
      }
     };
    
     public static void main(String[] args) {
      NotifIconSrvc app = new NotifIconSrvc();
      app.enterEventDispatcher();
     }
    }  
    

    主要应用:

    public class NotifIconApp extends UiApplication 
        implements GlobalEventListener {    
     private Bitmap mIcon = Bitmap.getBitmapResource("icon.png");
     private Bitmap mIconActive = 
            Bitmap.getBitmapResource("icon_active.png");
     private Scr mScreen = new Scr();
    
     public NotifIconApp() {
      addGlobalEventListener(this);
      pushScreen(mScreen);
     }
    
     public static void main(String[] args) {
      NotifIconApp app = new NotifIconApp();
      app.enterEventDispatcher();
     }
    
     public void eventOccurred(long guid, int count, int size, 
            Object object0, Object object1) {
      if (0x5a9f7caa171ab7b8L == guid) {
                        Bitmap icon = getUpdateIconBitmap(mIcon, count, size);
       HomeScreen.updateIcon(icon);
       Bitmap rolloverIcon = 
                            getUpdateIconBitmap(mIconActive, count, size);
       HomeScreen.setRolloverIcon(rolloverIcon);
       mScreen.updateScreen(count, size);
      }
     }
    
     private Bitmap getUpdateIconBitmap(Bitmap bmp, int count, int size) {
      int width = bmp.getWidth();
      int height = bmp.getHeight();
      Bitmap iconBmp = new Bitmap(width, height);
      Graphics g = new Graphics(iconBmp);
      XYRect rect = new XYRect(0, 0, width, height);
      g.drawBitmap(rect, bmp, 0, 0);
    
      g.setFont(g.getFont().derive(Font.BOLD, 20, Ui.UNITS_px,
        Font.ANTIALIAS_STANDARD, Font.COLORED_OUTLINE_EFFECT));
    
      String text = Integer.toString(count);
      g.setColor(Color.BLACK);
      g.drawText(text, 0, 2);
    
      text = Integer.toString(size) + " Kb";
      g.setColor(Color.GREEN);
      g.drawText(text, 0, height - 22);
      return iconBmp;
     }
    }
    
    class Scr extends MainScreen {
     LabelField mMessages;
     String mLabelText = "message count: ";
     String mTitleText = "message counter";
    
     public Scr() {
      add(mMessages = new LabelField(mLabelText));
      setTitle(mTitleText);
     }
    
     void updateScreen(int count, int size) {
      StringBuffer sb = new StringBuffer(Integer.toString(count));
      sb.append("/");
      sb.append(Integer.toString(size));
      sb.append("Kb");
      String text = sb.toString();
      setTitle(mTitleText + "(" + text + ")");
      mMessages.setText(mLabelText + text);
     }
    
     protected void makeMenu(Menu menu, int instance) {
      super.makeMenu(menu, instance);
      menu.add(mMenuGoBG);
     }
    
     MenuItem mMenuGoBG = new MenuItem("go background", 0, 0) {
      public void run() {
       UiApplication.getUiApplication().requestBackground();
      }
     };
    }
    

    【讨论】:

      猜你喜欢
      • 2010-11-30
      • 2014-07-15
      • 1970-01-01
      • 2011-02-19
      • 2010-12-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多