【问题标题】:Loading screen in j2me在 j2me 中加载屏幕
【发布时间】:2011-03-24 10:12:14
【问题描述】:

我想在我的应用程序中加载屏幕,以便它在互联网连接启动时出现,而当我从 web 服务获取数据时加载屏幕隐藏。

我曾尝试使用 .gif 文件。它在我制作的仅显示 .gif 文件的简单应用程序中正常工作。但是当我将此代码与我的 applicationj 集成时,它会显示错误。

错误是:

TRACE: <at java.lang.IllegalArgumentException>, Exception caught in Display class
java.lang.IllegalArgumentException
        at javax.microedition.media.Manager.createPlayer(), bci=8
        at com.semaphore.GifCanvas.<init>(GifCanvas.java:41)
        at com.semaphore.CompanySplashScreen.dismiss(CompanySplashScreen.java:89)
        at com.semaphore.CompanySplashScreen.keyPressed(CompanySplashScreen.java:78)
        at javax.microedition.lcdui.CanvasLFImpl.uCallKeyPressed(), bci=19
        at javax.microedition.lcdui.DisplayableLFImpl.uCallKeyEvent(), bci=146
        at javax.microedition.lcdui.Display$DisplayEventConsumerImpl.handleKeyEvent(), bci=30
        at com.sun.midp.lcdui.DisplayEventListener.process(), bci=277
        at com.sun.midp.events.EventQueue.run(), bci=179
        at java.lang.Thread.run(Thread.java:619)

我用来执行 .gif 文件的代码是:-

InputStream ins = getClass().getResourceAsStream("/loading.gif");
        try {
            player = Manager.createPlayer(ins, "image/gif");
             player.prefetch();
             player.setLoopCount(10);

        player.start();
        } catch (IOException ex) {
            ex.printStackTrace();
        } catch (MediaException ex) {
            ex.printStackTrace();
        }
        if ((vidc = (VideoControl) player.getControl("VideoControl")) != null)
        vidc.initDisplayMode(VideoControl.USE_DIRECT_VIDEO, this);
        try {
            vidc.setDisplayLocation(2, 2);
            vidc.setDisplaySize(getWidth()/2,getHeight()/2);
        }
        catch (MediaException me) {}
        vidc.setVisible(true);

我该如何解决这个问题?

【问题讨论】:

    标签: java-me


    【解决方案1】:

    根据documentation,您的 InputStream 为空。
    检查您的资源是否正确放置。使用该路径,它应该位于项目的根目录(或 src 目录,我不确定)。但请检查一下。

    【讨论】:

    • 感谢您的回复,我得到了解决方案。但现在的问题是我的代码在模拟程序中正常工作。但在索尼 erricsonT700 设备中无法正常工作。你能解释一下为什么它没有在设备。我曾尝试在 sonyerricson 论坛中找到此问题,但找不到任何解决方案。如果您有解决方案,请帮助我
    • @shweta 无法正常工作的原因有很多...您需要提供更多详细信息
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多