2012-06-03 22 views
0

我想使用手機的攝像頭與下面的代碼段J2ME拋光snapshotscreen

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

捕捉圖像,我得到一個空值返回。我的目標設備是具有mmapi功能的nokia/2700_classic,我不明白爲什麼它不起作用。有人有任何建議嗎?

+0

找到了解決方案,快照屏幕需要將樣式附加到它上面,如下所示://#style snapshotScreen snapShotScreen = new SnapshotScreen(「Snapshot」); – jade

回答

0

僅供參考,

對於Android相機的工作,你需要編輯MidletBridge.java文件。 這個文件,你會發現:

J2ME-Polish_Root \ j2mepolish-SRC \ J2ME的\ src \日\足夠\拋光\機器人\ MIDlet的\ MidletBridge.java

您將需要添加通用的Android攝像頭代碼在兩個方法(在MidletBridge活動範圍內),藏漢作爲公共字節[]中檢索數據時,你已經採取了照片後,點擊保存設置的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-波蘭人,而且看起來他們似乎沒有發佈過它。如果你真的想要所有的來源...去打擾他們。