我正在尝试使用手机的摄像头来捕获带有以下片段的图像
snapShotScreen = new SnapshotScreen( "Snapshot" );
snapShotScreen.addCommand(cmdBack );
snapShotScreen.addCommand(cmdCapture);
snapShotScreen.setCommandListener( new ThreadedCommandListener( this ) );
this.display.setCurrent(snapShotScreen);然后我得到一个空值返回。我的目标设备是nokia/2700_classic,它有mmapi功能,我还是不明白为什么它不能工作。有谁有什么建议吗?
发布于 2012-12-11 03:29:26
仅供参考,
要让安卓摄像头工作,你需要编辑MidletBridge.java文件。您将找到以下文件:
J2ME-Polish_Root\j2mepolish-src\j2me\src\de\enough\polish\android\midlet\MidletBridge.java
您需要添加两种方法的通用安卓相机代码(在MidletBridge活动中)以及一个公共byte[],以便在拍摄照片、单击保存并设置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 polish应用程序中通过调用
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用户都会非常高兴。适用于黑莓、诺基亚、安卓以及windows ce。
顺便说一句..当时我已经把整段代码发给了J2ME-波兰人,但看起来他们并没有发布。如果你真的想要所有的源代码..。去打扰他们吧。
https://stackoverflow.com/questions/10867445
复制相似问题