j2me polish snapshotscreen

196 views Asked by At

I am trying to use the phone's camera to capture images with the following snippet

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

and i get a null value returned. my target device is nokia/2700_classic which has mmapi capability, i don't still understand why it's not working. is anyone having any suggestion?

1

There are 1 answers

0
Pierre On

FYI,

For the Android camera to work, you'll need to edit the MidletBridge.java file. This file you will find:

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

You will need to add the generic android camera code in two methods (within the MidletBridge Activity) aswell as a public byte[] to retreive the data after you have taken a picture, clicked save and set the byte[] image:

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;
        }
}

After you have done this, you will need to instantiate the MidletBridge anywhere in your j2me polish application by calling

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.

I hope this helps somebody as I have taken weeks to come this far. My application worked well and was sold. I lost the source code, otherwise all of the J2ME-Polish users would have been very happy. Worked with Blackberry, nokia, android as well as windows ce.

BTW.. I have sent that whole piece of code to J2ME-Polish people at that time, and it doesnt look like they have published it. If you really want all the source... Go and bother them.