【问题标题】:j2me polish snapshotscreenj2me波兰快照屏幕
【发布时间】:2012-06-03 02:26:37
【问题描述】:

我正在尝试使用手机的摄像头通过以下 sn-p 捕获图像

        snapShotScreen = new SnapshotScreen( "Snapshot" );
        snapShotScreen.addCommand(cmdBack );
        snapShotScreen.addCommand(cmdCapture);
        snapShotScreen.setCommandListener( new ThreadedCommandListener( this ) );
        this.display.setCurrent(snapShotScreen);

我得到一个空值返回。我的目标设备是具有 mmapi 功能的 nokia/2700_classic,我仍然不明白为什么它不工作。有人有什么建议吗?

【问题讨论】:

  • 找到了解决方案,快照屏幕需要像这样附加一个样式: //#style snapshotScreen snapShotScreen = new SnapshotScreen("Snapshot");

标签: java-me j2mepolish


【解决方案1】:

仅供参考,

要使 Android 摄像头正常工作,您需要编辑 MidletBridge.java 文件。 你会发现这个文件:

J2ME-Polish_Root\j2mepolish-src\j2me\src\de\enough\polish\android\midlet\MidletBridge.java

您需要在两种方法中(在 MidletBridge Activity 中)添加通用 android 相机代码以及公共 by​​te[] 以在您拍照后检索数据,单击保存并设置 byte[] 图像:

MidletBridge.java file:

public byte[] imagebytearray = null;

public void startCameraIntent(){
        Intent i = new Intent("android.media.action.IMAGE_CAPTURE");
        startActivityForResult(intent, 10121);
}

@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        switch (requestCode) {
            case 10121: 
                imagebytearray = (byte[]) data.getExtras().get("data");
                break;
        }
}

完成此操作后,您需要通过调用在 j2me 波兰应用程序中的任何位置实例化 MidletBridge

de.enough.polish.android.midlet.MidletBridge m = new de.enough.polish.android.midlet.MidletBridge();
m.startCameraIntent();
//I couldnt remember if the code continues here after you have taken the picture
byte[] img = m.imagebytearray;
//If the code doesnt pause here, you can just use a button to retreive the image or store the 
//image within the RMSStorage -- need some more code for that -- and then retreive it that way.

我希望这对某人有所帮助,因为我花了数周时间才走到这一步。我的应用程序运行良好并被出售。我丢失了源代码,否则所有 J2ME-Polish 用户都会非常高兴。与黑莓、诺基亚、android 以及 windows ce 合作。

顺便说一句.. 我当时已经把整段代码发给了 J2ME-Polish 的人,看起来他们并没有发布。如果你真的想要所有的来源......去打扰他们。

【讨论】:

    猜你喜欢
    • 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
    相关资源
    最近更新 更多