×

Discussion Board

Results 1 to 6 of 6
  1. #1
    Registered User
    Join Date
    Oct 2010
    Posts
    4

    MIDlet runs on emulator crashes on n97

    Hi people,

    I have a problem and am unsure if it is my coding that is wrong or not (it is my first try at j2me). In the emulator everything runs fine, when I run it on an n97 mini it crashes periodically... not necessarily in the same place sometimes immediately sometimes after some 30 clicks into the application... any hints off the top or would you need a sample of my code?

  2. #2
    Super Contributor
    Join Date
    Apr 2003
    Location
    USA, CA
    Posts
    7,191

    Re: MIDlet runs on emulator crashes on n97

    Please include a little more information about your MIDlet...

    Such as:
    - what does it do?
    - are you using a lot of memory?
    - are you getting any Exceptions?
    - etc..

    Hartti

  3. #3
    Registered User
    Join Date
    Oct 2010
    Posts
    4

    Re: MIDlet runs on emulator crashes on n97

    Okay..
    we have a website that deals with supermarkets... the markets update their current items on sale, and keep an up to date listing of locations and hours. The midlet connects to the website grabs the info about the stores, their sales and locations....

    no problems getting all the info, the problem seems to be centered around the locations, when you choose to enter locations in this section it seems to crash at random times... sometimes when you select a location, sometimes when you hit select to view the map of the location, sometimes it crashes one second after entering the location screen....

    Can provide a link to the jar/jad if that is allowed

    Edit: i have not seen exceptions on the emulator, i wouldn't say it uses a lot of memory, jar is around 160k, using List, Form and CustomItems for all my display purposes

  4. #4
    Registered User
    Join Date
    Oct 2010
    Posts
    4

    Re: MIDlet runs on emulator crashes on n97

    I will post some code maybe someone can chime in if they see something wrong.

    This is the CommandAction that initiates the loading of the screen in question:
    Code:
    if (index == 1){
    	manager.show(instructionScreen("Za prikaz lokacije dućana označi dućan i pritisni SELECT"));
    	Thread t = new Thread(){
    		public void run(){
    			getLokacije();
    		}
    	};
    	t.start();
    }
    And here is the code to load in the screen:

    Code:
    private void getLokacije() {
    	worker.setURL("http://www.example.com", true);
    	try {
    		worker.queryServer();
    	} catch (IOException e) {
    		manager.show(mainScreen);
    	}
    	parser.setRawtext(worker.getNews());
    	rawLokacije = parser.splitLine(true);
    	selectedZupanija = 0;
    	manager.next(getLokacijeScreen());
    }
    
    private Displayable getLokacijeScreen(){
    	//System.out.println(rawLokacije.size());
    	lokacijeScreen = new Form(ducani[selectedDucan] + " - lokacije");
    	
    	cg = new ChoiceGroup("Odaberi za prikaz po županijama", Choice.POPUP, zupanije, null);
    	cg.setSelectedIndex(selectedZupanija, true);
    	lokacijeScreen.append(cg);
    		
    	for(i=0; i<rawLokacije.size(); i++){
    		Lokacije l = (Lokacije) rawLokacije.elementAt(i);
    		if (selectedZupanija == 0){
    			cloki = new CustomLokItem(null, this, l.grad, l.adresa, l.week_start, l.week_close, l.sat_start, l.sat_close, l.sun_start, l.sun_close);//, l.google);
    			lokacijeScreen.append(cloki);
    		} else {
    			if (l.zup_id == selectedZupanija){
    				cloki = new CustomLokItem(null, this, l.grad, l.adresa, l.week_start, l.week_close, l.sat_start, l.sat_close, l.sun_start, l.sun_close);//, l.google);
    				lokacijeScreen.append(cloki);
    			}
    				
    		}
    
    	}
    	lokacijeScreen.setItemStateListener(this);
    	lokacijeScreen.setCommandListener(this);
    	lokacijeScreen.addCommand(back);
    	return lokacijeScreen;
    }

  5. #5
    Super Contributor
    Join Date
    Apr 2003
    Location
    USA, CA
    Posts
    7,191

    Re: MIDlet runs on emulator crashes on n97

    Did I understood correctly that you do not use Location API to get any locations, but you get them from some service over HTTP (or similar) connection? (just wondering if Location API could be a problem here...)
    And no, I do not have any idea based on your code which could be wrong... :-(

    Hartti

  6. #6
    Registered User
    Join Date
    Oct 2010
    Posts
    4

    Re: MIDlet runs on emulator crashes on n97

    yeah i am using google static maps for my locations... could the problem be in the way i set up my CustomItem?

    Edit: quick side question... could it have anything to do with the application being unsigned?

    Code:
    import javax.microedition.lcdui.Command;
    import javax.microedition.lcdui.CustomItem;
    import javax.microedition.lcdui.Font;
    import javax.microedition.lcdui.Graphics;
    import javax.microedition.lcdui.Item;
    import javax.microedition.lcdui.ItemCommandListener;
    
    public class CustomLokItem extends CustomItem{
    	String grad, adresa, ws, wc, sats, satc, suns, sunc, google;
    	SMClaw midlet;
    	boolean selected;
    	
    	public CustomLokItem(String label, SMClaw mid, String g, String a, String weeks, String weekc, String sts, String stc, String sns, String snc, String goo) {
    		super(label);
    		midlet = mid;
    		grad = g;
    		adresa = a;
    		ws = weeks;
    		wc = weekc;
    		sats = sts;
    		satc = stc;
    		suns = sns;
    		sunc = snc;
    		google = goo;
    		selected = false;
    	}
    
    	protected int getMinContentHeight() {
    		return 60;
    	}
    
    	protected int getMinContentWidth() {
    		return 176;
    	}
    
    	protected int getPrefContentHeight(int width) {
    		return 100;
    	}
    
    	protected int getPrefContentWidth(int height) {
    		return 320;
    	}
    
    protected void paint(Graphics g, int width, int height) {
    	Font font = g.getFont();
    	    font = Font.getFont(Font.FACE_SYSTEM, Font.STYLE_PLAIN, Font.SIZE_SMALL);
    	    g.setFont(font);
    	    int fontHeight = font.getHeight();
    		g.setColor( 255, 255, 255 );
    		g.fillRect( 0, 0, width, height );
    		g.setColor(0, 0, 0);
    		if (selected){
    			g.setColor(255, 0, 0);
    			g.drawRect(0, 0, width, height);
    		}
    
    		g.setColor(255, 0, 0);
    		g.drawString(grad, 10, 0, 0);
    		g.setColor(0,0,0);
    		g.drawString(adresa, 10, fontHeight+2, 0);
    		g.drawString("Radnim danom: " + ws + " - " + wc, 10, 2*fontHeight+2, 0);
    		g.drawString("Subota: " + ws + " - " + wc, 10, 3*fontHeight+2, 0);
    		g.drawString("Nedjelja: " + ws + " - " + wc, 10, 4*fontHeight+2, 0);
    	}
    
    	protected void pointerPressed(int x, int y){
    		if (!selected){
    			selected = true;
    			repaint();
    		}
    	}
    	
    	protected void pointerReleased(int x, int y){
    		midlet.lokacijaClicked(google);
    	}
    	
    	protected boolean traverse(int dir, int viewportWidth, int viewportHeight,int[] visRect_inout){
    		return false;
    	}
    	
    	protected void traverseOut(){
    		if (selected){
    			selected = false;
    			repaint();
    		}
    	}
    }
    Last edited by Blubba; 2010-12-10 at 20:37.

Similar Threads

  1. Midlet runs much slower on N95 than N70
    By pmcquillan in forum Mobile Java General
    Replies: 5
    Last Post: 2007-11-29, 16:55
  2. Midlet runs in S40 but not in S60
    By bemar in forum Mobile Java Tools & SDKs
    Replies: 2
    Last Post: 2007-07-13, 09:02
  3. Midlet runs in emulator but not in handset - please help
    By gmweb.de in forum Mobile Java General
    Replies: 1
    Last Post: 2004-12-18, 18:01
  4. N7650 runs MIDlet, but N6600 doesn't
    By alekar in forum Mobile Java General
    Replies: 2
    Last Post: 2004-03-16, 13:35
  5. Midlet runs on 7650 emulator but not on real device
    By hlehtimaki in forum Mobile Java General
    Replies: 1
    Last Post: 2002-07-15, 09:24

Posting Permissions

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