×

Discussion Board

Results 1 to 2 of 2
  1. #1
    Regular Contributor
    Join Date
    Nov 2009
    Posts
    52

    Unhappy Problem with Image show application

    hello everyone

    i have creation some simple image-show application,i am testing this application with Nokia N97 Emulator and Nokia N97 Device both ,when ever user click on first shell image, i open the second shell ,
    and when user coming on second shell , i have putting Next and Previous command on second shell and implement its selectionlistner event.
    on clicking next i appear next image, and clicking on previous i appear previous image in shell,

    Whenever continuously pressing Next command , i reach the last image(around i have putting 38 jpg image in res folder with name like image1, image2.....image38) then i have dispose the second shell. and user come on the first splash shell, when user running second time it is also running perfect, after the last image of second shell i dispose the second shell ,once again user come on the first splash shell , and when the user running third time it gives error:- "Application closed by Invalid image"


    in short i need my application run continuously, but i get error at third time with this error:-"Application closed by Invalid image"

    pleas help me in this issues it is urgent

    i have putting my code below for first and second shell,

    //first shell
    import javax.microedition.midlet.*;
    import org.eclipse.ercp.swt.mobile.MobileDevice;
    import org.eclipse.ercp.swt.mobile.MobileShell;
    import org.eclipse.ercp.swt.mobile.Screen;
    import org.eclipse.swt.SWT;
    import org.eclipse.swt.events.MouseEvent;
    import org.eclipse.swt.events.MouseListener;
    import org.eclipse.swt.graphics.Image;
    import org.eclipse.swt.layout.RowLayout;
    import org.eclipse.swt.widgets.Display;
    import org.eclipse.swt.widgets.Label;

    public class IQsplashmidlet extends MIDlet implements Runnable,MouseListener{
    public Thread UIThread1;
    private boolean running;
    private Display display;
    public MobileShell shell;
    private Label imgLabel,l2,l1;
    Image s1,s2;
    public void startApp() {
    if(this.UIThread == null){
    try{
    UIThread = new Thread(this);
    }
    catch(IllegalThreadStateException t1){
    System.out.println("thread exception" +t1);
    }
    UIThread.start();
    }
    }


    public void pauseApp() {
    }

    public void destroyApp(boolean unconditional) {
    exitEventLoop();

    try {
    UIThread.join();
    } catch (InterruptedException e) {
    }
    }

    void exitEventLoop() {
    running = false;
    display.wake();
    }
    public void run() {
    running = true;
    display = new Display();
    shell = new MobileShell(display,SWT.MAX);
    shell.changeTrim(SWT.CLOSE|SWT.MIN|SWT.MAX|SWT.RESIZE,MobileShell.NO_STATUS_PANE);

    // shell.setLayout(new FillLayout(SWT.VERTICAL));
    shell.setFullScreenMode(true);
    RowLayout layout = new RowLayout(SWT.VERTICAL);
    layout.wrap = true;
    layout.fill = true;
    layout.justify = false;
    layout.marginLeft=17;
    layout.spacing=20;

    shell.setLayout(layout);
    shell.open();
    MobileDevice device = MobileDevice.getMobileDevice();
    final Screen[] screens = device.getScreens();
    screens[0].setOrientation(Screen.PORTRAIT);

    shell.setActive();
    shell.layout();
    s1 = new Image(display,getClass().getResourceAsStream("/res/splash.jpg"));
    s2 = new Image(display,getClass().getResourceAsStream("/res/start.png"));
    imgLabel = new Label(shell,SWT.CENTER);
    imgLabel.setImage(s1);
    l2 =new Label(shell,SWT.CENTER);
    l2.setImage(s2);
    l2.addMouseListener(this);
    //shell.redraw();

    while (running && !shell.isDisposed()) {
    if (!display.readAndDispatch()) {
    display.sleep();

    }
    }
    display.dispose();
    s1.dispose();
    s2.dispose();
    l1.dispose();
    l2.dispose();
    imgLabel.dispose();
    shell.dispose();
    notifyDestroyed();
    }

    public void mouseDoubleClick(MouseEvent arg0) {

    }

    public void mouseDown(MouseEvent arg0) {
    new SecondShell();
    }

    public void mouseUp(MouseEvent arg0) {

    }
    }

    //second shell


    import java.io.IOException;
    import java.io.InputStream;
    import org.eclipse.ercp.swt.mobile.Command;
    import org.eclipse.ercp.swt.mobile.MobileShell;
    import org.eclipse.swt.SWT;
    import org.eclipse.swt.SWTException;
    import org.eclipse.swt.events.SelectionEvent;
    import org.eclipse.swt.events.SelectionListener;
    import org.eclipse.swt.graphics.Image;
    import org.eclipse.swt.graphics.ImageData;
    import org.eclipse.swt.layout.RowLayout;
    import org.eclipse.swt.widgets.Button;
    import org.eclipse.swt.widgets.Composite;
    import org.eclipse.swt.widgets.Display;
    import org.eclipse.swt.widgets.Label;
    import org.eclipse.swt.widgets.MessageBox;


    public class SecondShell implements SelectionListener{
    public MobileShell shell;
    Command nextCommand,previouscommand;
    private Label imgLabel,title,notitle;
    private Image splash1,i1;
    Image i11;
    int count=0;
    InputStream s33;
    public static String PREFIX = "/res/image";
    public static String SUFFIX = ".jpg";
    private static final String BACK_COMMAND_TEXT1 = "Next";
    private static final String BACK_COMMAND_TEXT2 = "Start";

    public SecondShell(){

    shell = new MobileShell(Display.getCurrent(),SWT.MAX);
    shell.changeTrim(SWT.CLOSE|SWT.MIN|SWT.MAX|SWT.RESIZE,MobileShell.NO_STATUS_PANE);
    RowLayout layout = new RowLayout(SWT.VERTICAL);
    layout.wrap = true;
    layout.fill = true;
    layout.justify = false;
    layout.marginLeft=17;
    layout.spacing=20;
    shell.setLayout(layout);
    shell.open();
    shell.layout();
    nextCommand = new Command(shell, Command.EXIT, 0);
    nextCommand.setText(BACK_COMMAND_TEXT1);
    nextCommand.addSelectionListener(this);

    previouscommand = new Command(shell, Command.OK, 1);
    previouscommand.setText("Previous");
    previouscommand.addSelectionListener(this);
    previouscommand.setEnabled(false);
    i1=getimage(count);
    imgLabel = new Label(shell,SWT.CENTER);
    imgLabel.setImage(i1);
    shell.redraw();
    }

    public void widgetSelected(SelectionEvent arg0) {
    if(arg0.widget.equals(nextCommand)){
    if(nextCommand.getText().equals(BACK_COMMAND_TEXT1))
    {

    if(count>=0&&count<=36){

    count++;
    i1=getimage(count);
    imgLabel.setImage(i1);
    if(count==1){
    previouscommand.setEnabled(true);
    }
    }
    if(count>=37){
    nextCommand.setText(BACK_COMMAND_TEXT2);
    }


    }
    else if(nextCommand.getText().equals(BACK_COMMAND_TEXT2))
    {

    try{
    disposecontrol();

    } catch (IOException ex) {
    ex.printStackTrace();
    }

    }
    }
    else if(arg0.widget.equals(previouscommand)){
    if(count==37){

    nextCommand.setText(BACK_COMMAND_TEXT1);
    }

    if(count>0){
    count--;
    }
    if(count==0){
    previouscommand.setEnabled(false);
    }
    imgLabel.setImage(getimage(count));
    }

    }

    public void widgetDefaultSelected(SelectionEvent arg0) {

    }
    public Image getimage(int d){


    try{
    s33=getClass().getResourceAsStream(PREFIX + d + SUFFIX);
    splash1 = new Image(Display.getCurrent(),s33);
    }catch(SWTException s3){
    showmessage(s3.getMessage(),SWT.ICON_INFORMATION);
    }
    return splash1;
    }
    public void disposecontrol() throws IOException{
    nextCommand.dispose();
    previouscommand.dispose();

    splash1.dispose();
    // i11.dispose();
    s33.close();
    i1.dispose();
    imgLabel.dispose();
    shell.dispose();
    }



    public void showmessage(String msg,int icon){
    MessageBox t2 =new MessageBox(shell,icon);
    t2.setMessage(msg);
    t2.open();
    }

    }

  2. #2
    Registered User
    Join Date
    Mar 2010
    Posts
    24

    Post Re: Problem with Image show application

    i think u have not provide full code......
    bcoz i was trying to develop ur app , but there are lots off errors

    like...........(Red Marks @)

    1)
    display = new Display();
    shell = new MobileShell(display,SWT.MAX);
    2)
    Screen[] screens = device.getScreens();
    screens[0].setOrientation(Screen.PORTRAIT);
    3)
    s1 = new Image(display,getClass().getResourceAsStream("/res/splash.jpg"));
    s2 = new Image(display,getClass().getResourceAsStream("/res/start.png"));
    4)
    imgLabel.setImage(s1);
    5)
    l2.setImage(s2);
    6)
    if (!display.readAndDispatch())
    {
    display.sleep();
    }
    7)
    display.dispose();
    s1.dispose();
    s2.dispose();

    ..........
    i just created two class as per ur code...........
    if u solve this i will try to run & find out the problem......????

    All the Best,,,,,,,,,,,,,,,,,,,,,,,,,,,,,

Similar Threads

  1. Problem regarding creating ROM image
    By eternity007 in forum Symbian Tools & SDKs
    Replies: 2
    Last Post: 2009-05-21, 09:37
  2. Problem in mobile tracker application
    By vikasdeshpande in forum Mobile Java General
    Replies: 3
    Last Post: 2009-03-17, 14:11
  3. Replies: 8
    Last Post: 2009-01-20, 13:47
  4. Bluetooth OBEX ( image transfer using bluetooth ) problem
    By atiqkamran in forum Bluetooth Technology
    Replies: 7
    Last Post: 2008-08-14, 08:02
  5. show image on the form from memory
    By aaapigfly in forum Mobile Java Media (Graphics & Sounds)
    Replies: 2
    Last Post: 2007-08-27, 20:15

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×