在 BlackBerry JDE 4.5.0 的状态栏添加通知图标 [英] Add a notification icon at the status bar in BlackBerry JDE 4.5.0

查看:16
本文介绍了在 BlackBerry JDE 4.5.0 的状态栏添加通知图标的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I'm writing a Java application in BlackBerry JDE 4.5 that will start listening for some event at the start up. I want to display a small icon at the status bar.

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

I know its support in version 4.6.0 of the BlackBerry API set with ApplicationIcon, ApplicationIndicator and ApplicationIndicatorRegistry classes but which classes are there in BlackBerry JDE 4.5.0 API set?

更新

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

I think some support is there for 4.5.0 as I'm using Blackberry Pearl 8100 with OS v4.5.0.81 which displays Notification Icons at status bar for any incoming messages or calls.

我创建了 Alternale 入口点 &像下面这篇文章的主要 CLDC 应用程序,

I made the Alternale Entry point & Main CLDC app like this article below,

如何 - 为我的应用程序设置备用入口点

我有一篇文章,

如何 - 使正在运行的 UI 应用程序转到后台并在前台恢复

其中说

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

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

But in my case the main() is not getting called when I click on appIcon when the app is running in background.

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

It only updates appIcon & appName which is previously set in Alternate Entry Point.

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

So I m not getting where the control goes if its not calling main() when clicked on updatedIcon?

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

Is anyone has any idea on this issue?

我更新了 appIcon &应用名称.

I updated the appIcon & appName.

现在我想要的是当点击更新图标时,应该打开一个特定的屏幕&当用户返回主菜单时,应用程序应获得其原始图标、应用程序名称和应用程序名称.单击原始应用程序图标时,流程应通过 main() "

Now what I want is "When clicked on updatedIcon a particular screen should be opened & when the user goes back to Main Menu the app should get its original Icon, app name & the flow should go through main() when clicked on original app Icon"

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

I was thinking when I click on updated appIcon the control will go to main() but instead of calling main() it says,

Starting AppName
AppName already running

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

& directly it goes to first screen. and when I come back to Main Menu the app has updated icon & name

那么如何获得呢?

推荐答案

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

Unfortunately it's not possible. What you can do is update application icon.

还有其他通知方式:
Blackberry OS 4.5 应用程序的通知服务

替代文字 http://img211.imageshack.us/img211/4527/icoupdate1.jpg替代文字 http://img697.imageshack.us/img697/3981/icon.jpg替代文字 http://img687.imageshack.us/img687/256/iconactive.jpg替代文字 http://img130.imageshack.us/img130/3277/icoupdate2.jpg替代文字 http:///img691.imageshack.us/img691/6459/icoupdate3.jpg
后台运行应用程序:

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
Background running application:

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();
  }
 };
}

这篇关于在 BlackBerry JDE 4.5.0 的状态栏添加通知图标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆