Shr*_*yas 1 integration user-interface notifications blackberry rim-4.5
我正在BlackBerry JDE 4.5中编写一个Java应用程序,它将在启动时开始侦听某些事件.我想在状态栏中显示一个小图标.
我知道它在带有ApplicationIcon,ApplicationIndicator和ApplicationIndicatorRegistry类的BlackBerry API版本4.6.0中的支持,但是在BlackBerry JDE 4.5.0 API集中有哪些类?
更新
我认为4.5.0有一些支持,因为我使用的是带有OS v4.5.0.81的Blackberry Pearl 8100,它在状态栏上显示任何传入消息或呼叫的通知图标.
我制作了Alternale入口点和主要CLDC应用程序,如下文所述,
我有一篇文章,
其中表示
无论应用程序是否正在运行,备用条目将使用传入的参数调用main方法.
但在我的情况下,当应用程序在后台运行时单击appIcon时,不会调用main().
它仅更新先前在备用入口点中设置的appIcon和appName.
所以如果在点击updatedIcon时没有调用main(),那么我没有得到控件的位置?
有人对这个问题有任何想法吗?
我更新了appIcon&appName.
现在我想要的是"当点击updatedIcon时,应该打开一个特定的屏幕,当用户返回主菜单时,应用程序应该获得其原始图标,应用程序名称和流量应该通过main()点击原始应用程序图标"
我在想,当我点击更新的appIcon时,控件将转到main(),但它没有调用main(),
Starting AppName
AppName already running
Run Code Online (Sandbox Code Playgroud)
&直接进入第一个屏幕.当我回到主菜单时,应用程序已更新图标和名称
那怎么弄呢?
不幸的是,这是不可能的.您可以做的是更新应用程序图标.
还有其他通知方式:
Blackberry OS 4.5应用程序的通知服务
alt text http://img211.imageshack.us/img211/4527/icoupdate1.jpg alt text http://img697.imageshack.us/img697/3981/icon.jpg alt text http://img687.imageshack.us/ img687/256/iconactive.jpg alt text http://img130.imageshack.us/img130/3277/icoupdate2.jpg alt 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();
}
}
Run Code Online (Sandbox Code Playgroud)
主要应用:
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();
}
};
}
Run Code Online (Sandbox Code Playgroud)