我正在尝试播放录制的wave文件.在播放时,会在以下语句中引发异常:
Player player = Manager.createPlayer(is, "audio/mpeg");
Run Code Online (Sandbox Code Playgroud)
我播放wave文件的全部代码如下:
if (types[cnt].equals("audio/x-wav")) {
Class clazz = Class.forName("RecordAudio");
InputStream is =
clazz.getResourceAsStream("file:///SDCard/BlackBerry/original.wav");
//create an instance of the player from the InputStream
Player player = Manager.createPlayer(is, "audio/mpeg");
player.realize();
player.prefetch();
//start the player
player.start();
}
Run Code Online (Sandbox Code Playgroud)
可能是什么问题呢?
我需要在BlackBerry应用程序中从classpath读取资源文件.我的项目的目录结构很常见:在src目录下有2个子目录,一个表示源程序包root,另一个表示资源根目录.
当我尝试从类路径中读取任何资源时,Class.getResourceAsStream方法会返回null
InputStream rStream = null;
String path = "/res/default_config.xml";
try {
rStream = getClass().getResourceAsStream(path);
} finally {
try {
if (rStream != null) {
byte[] data = IOUtilities.streamToBytes(rStream);
System.out.println(new String(data));
rStream.close();
}
} catch (IOException e) {
System.out.println(e.getMessage());
}
}
Run Code Online (Sandbox Code Playgroud)
我该如何正确读取classpath资源?
在BlackBerry我开发了一个屏幕,在背景中显示大小为480×360的图像.我的BB屏幕大小为480×360.由于图像有点大,当我垂直滚动时,屏幕会滚动并扰乱我的屏幕.我想锁定滚动,这样我就无法进行垂直滚动.可能是我问一个非常简单的问题,但我现在没有时间去谷歌了.请帮我这样做
我的代码如下:
public LaunchXtcMsngrScreen()
{
int intwidth = Display.getWidth();
int intheight = Display.getHeight();
//getting the height/width of BB screen
Debugger.debug(UrlInfo.workflow_File,"Screen Height ="+intheight);
Debugger.debug(UrlInfo.workflow_File,"Screen Width ="+intwidth);
BMbackground = Bitmap.getBitmapResource("xtclogo.jpg");
VerticalFieldManager VFM = new VerticalFieldManager(VerticalFieldManager.USE_ALL_WIDTH
| VerticalFieldManager.USE_ALL_HEIGHT
| VerticalFieldManager.NO_VERTICAL_SCROLL
| VerticalFieldManager.NO_VERTICAL_SCROLLBAR)
{
//Override the paint method to draw the background image.
public void paint(Graphics graphics)
{
//Draw the XTC Messenger logo
graphics.drawBitmap(0, 0,Display.getWidth(),Display.getHeight(),BMbackground, 0, 0);
super.paint(graphics);
}
};
Bitmap registerbitmap = Bitmap.getBitmapResource("register_button.PNG");
BFregister = new ImageButtonField(registerbitmap);
BFregister.setMargin(245,0,0,190);//vertical pos,0,0,horizontal pos
VFM.add(BFregister);
add(VFM);
} …Run Code Online (Sandbox Code Playgroud) 我想知道如果我接到黑莓/安卓设备的电话,是否可以通过编程方式区分是陆线呼叫还是移动线路呼叫?
谢谢你的帮助
我在一些标签字段后面添加了一些自定义按钮字段.打开应用程序时,第一个按钮区域会获得焦点,但打开屏幕时我不需要焦点.如何避免重点打开屏幕?
我是这两个联系的新手.我以前曾经使用HTTP连接,现在我想转移到一种新的连接类型.我搜索了连接并获得了这两种类型:套接字连接和XMPP连接.它们之间的主要区别是什么?我想将它用于聊天应用程序,以便更好地推荐哪种类型?谢谢
我正在尝试使用BlackBerry JDE 6.0的MenuItem类,我遇到错误"构造函数MenuItem String(String,int,int)已被弃用".我正在使用MainScreen类下的子类实现它.以下是不推荐使用的示例代码:
public class UiFunMainScreen extends MainScreen{
class LoginMenuItem extends MenuItem {
public LoginMenuItem() {
super("Login", 20, 10);
}
public void run() {
login();
}
}
class ClearMenuItem extends MenuItem {
public ClearMenuItem() {
super("Clear", 10, 20);
}
public void run() {
clearTextFields();
}
}
}
Run Code Online (Sandbox Code Playgroud) 我在屏幕的底栏放了一个按钮.底栏基本上是具有背景图像的水平场管理器.现在,此按钮(基本上是一个继续按钮)用于移动到下一个屏幕.但如果我点击管理员并在按钮外面,它将进入下一个屏幕.所以click事件正在对总经理起作用,下面是代码:
HorizontalFieldManager hfmBtn = new HorizontalFieldManager(Field.FIELD_BOTTOM)
{
protected void sublayout(int nMaxWidth, int nMaxHeight)
{
height = Bitmap.getBitmapResource("buttom_bar.png").getHeight();
super.sublayout(nMaxWidth, nMaxHeight);
setExtent(getPreferredWidth(), getPreferredHeight());
}
public int getPreferredHeight()
{
return height;
}
public int getPreferredWidth()
{
return screenWidth;
}
};
hfmBtn.setBackground(BackgroundFactory.createBitmapBackground(Bitmap.getBitmapResource("buttom_bar.png")));
btnContinue = new CustomButtonImageField("Continue", Bitmap.getBitmapResource("button_normal.png"), Bitmap.getBitmapResource("button_hover.png"),Field.FIELD_VCENTER);
btnContinue.setChangeListener(this);
btnContinue.setMargin(10, 0, 0, screenWidth/3);
hfmBtn.add(btnContinue);
add(hfmBtn);
Run Code Online (Sandbox Code Playgroud)
这是点击事件:
public void fieldChanged(Field field, int context)
{
if(field == btnContinue)
{
UiApplication.getUiApplication().pushScreen(new SendListScreen(platformContext,strItemList));
}
}
Run Code Online (Sandbox Code Playgroud)
请帮帮我..我在BB Bold 9790测试.
对于下面显示的代码,当我按下选项按钮(由optionsButton变量给出)时,没有出现弹出屏幕.我究竟做错了什么 ?
optionsButton.setChangeListener(new FieldChangeListener() {
public void fieldChanged(Field arg0, int arg1) {
PopupScreen popup = new PopupScreen(new VerticalFieldManager());
popup.add(new LabelField("Hello!"));
Border border = BorderFactory.createSimpleBorder(
new XYEdges(), Border.STYLE_TRANSPARENT);
popup.setBorder(border);
}
});
Run Code Online (Sandbox Code Playgroud)