   HTML connection[j2me]
  Hello.I'm trying to make a html connection using MIDP. When my first try didn't work I tried making the same connection from a new midlet, in the midlet itself. And it worked.So now I wanna use this working connection in my gamescreen class(extends canvas) were I have the key input functions. But I can't get it to work.Any ideas?Thanks.   
  More information is needed.What do you mean by "not working"? What errors did you get?Post some relevant code.shmoove   ;  This is the code that works:[source lang=java]import java.io.*;import javax.microedition.midlet.*;import javax.microedition.io.*;import javax.microedition.lcdui.*;/** * An example MIDlet to fetch a page    using an HttpConnection.*/public class SecondExample extends MIDlet {  private Display display;  private String url = "http://www.smet.walrus.talkhost.info/index.php?name1=wakka&score1=5440";    public SecondExample() { display = Display.getDisplay(this);    }  /**   * startApp is invoked when    * the MIDlet is activated.  */  public void startApp() {    //The specified URL is overridden//in the descriptor    try { send(url);    } catch(IOException e) { // handle the exception    }  }  private void send(String url) throws IOException {    StringBuffer b = new StringBuffer();    InputStream is = null;    HttpConnection c = null;    TextBox t = null;    try{ long len = 0 ; int ch = 0; c = (HttpConnection)Connector.open(url); is = c.openInputStream();    } finally { is.close(); c.close();    }    display.setCurrent(t);  }  /**   * Pause, discontinue....  */  public void pauseApp() { }  /**   * Destroy must cleanup everything.  */  public void destroyApp(boolean unconditional) { }}This is the function that sends the data in the one that don't work:[source lang=java]private void send() throws IOException    {   String url;   url = "www.smet.walrus.talkhost.info/index.php?";   for(int i = 0; i < names.length; i++)   {   url += names + "&" + scores + "&";   } InputStream is = null;   HttpConnection c = null;   try    {  c = (HttpConnection)Connector.open(url);  is = c.openInputStream();   }    finally    {  is.close();  c.close();   }   }And this is the code in the gamescreen class:[source lang=java]protected void keyPressed( int keyCode ){//get the game action from the passed keyCodeint gameAction = getGameAction( keyCode );switch( gameAction ){case FIRE:try { highscore.send(); } catch(Exception  e) {}    colour = 0xFFFFFF;break;}}This is supposed to send the highscore data when the fire button is pressed, and change color so you can see that the data have been sent. The error I get is: java.lang.NullPointerException and then the screen locks up...it never changes color.Edit: changed it a little, so now it don't lock up, but I dont get any html data to the page. And the green network light don't light up, as it does in the one that work.I think it has something doing with that I don't get any question if its ok to send html, because I get that with the first midlet.Plese say if I missed some important information.Thanks.[Edited by - walle on November 18, 2005 5:36:44 AM];  Well, network code should run on a separate thread. So first try doing that.Here's a tutorial about that.shmoove   ;  I would also suggest getting the URL from the jad file, for it is easier to modify later on. you can do it like this//this is valid where "URL" is in the midlet like this://URL: http://google.com String url = this.getAppProperty("URL");doing alot of web programming on cell phones I can tell you this can be very useful especially when urls change unexpectedly [grin]~guyaton   ;Quote:Original post by guyatonI would also suggest getting the URL from the jad file, for it is easier to modify later on. you can do it like this*** Source Snippet Removed ***doing alot of web programming on cell phones I can tell you this can be very useful especially when urls change unexpectedly [grin]~guyatonUnfortunatelly, that won't work in the cases there is no .jad file involved, like when you install the app via bluetooth (only the jar file is sent).;  I've only done Bluetooth deployment via the 60 series Nokia phones, but those seem to support JAD files just fine. You just have to send both the JAD and the JAR to the phone and click on the JAD in your inbox. Are there any phones that require Bluetooth deployment that don't support this method?   ;  Heh, i never did it that way. I only send the jar to the phone and install it.Do you know if using both files, as you do, you can access the properties in the jad file after installing it via bluetooth?   ;Quote:Original post by BlewHeh, i never did it that way. I only send the jar to the phone and install it.Do you know if using both files, as you do, you can access the properties in the jad file after installing it via bluetooth?Yes. If you use both files you can access properties in the jad file. This is how locales are often interpreted on devices that support multiple languages.   