×

Discussion Board

Results 1 to 7 of 7
  1. #1
    Registered User
    Join Date
    May 2008
    Posts
    17

    How to open web page from Midlet

    Dear All

    How can i open web page(for example http://forum.nokia.com ) from my midlet .(i.e after making HTTP connection what shold i do ) ?


    Thanks in advance
    Nabil

  2. #2
    Nokia Developer Champion
    Join Date
    Sep 2007
    Posts
    915

    Re: How to open web page from Midlet

    I am writing some code here for it. Let me know if you face any problem in it.


    String url = "http://jonathanknudsen.com/simple";
    InputConnection ic = (InputConnection)Connector.open(url);
    InputStream in = ic.openInputStream();
    // Read stuff from the InputStream
    ic.close();



    -Kartik Trivedi

  3. #3
    Super Contributor
    Join Date
    Mar 2008
    Location
    The Capital of INDIA
    Posts
    4,328

    Thumbs up Re: How to open web page from Midlet

    Hi,
    What i guesss is that you wana make a http connection..

    or what..
    if yes then I think you made a mistake.Connector.open() return value must be typecast in HttpConnection,however you have made it InputConnection.
    try this out


    String url = "http://jonathanknudsen.com/simple";

    HttpConnection connection = (HttpConnection) Connector.open (urlToCall);
    inputStream = connection.openInputStream ();
    contentLength = ( int )connection.getLength ();

    // Read stuff from the InputStream.
    // and then you close the stream.

    if ( connection != null )
    {
    try
    {
    connection.close ();
    }
    catch (IOException ex)
    {
    ex.printStackTrace ();
    }
    }
    if( inputStream != null )
    inputStream = null;
    Thanks with Regards,

    R a j - The K e r n e l


    Join Delhi-NCR Nokia Developer's Community,

  4. #4
    Registered User
    Join Date
    May 2008
    Posts
    17

    Re: How to open web page from Midlet

    First Thanks for your replies


    but i do that already ,
    what should i do after
    InputStream in = ic.openInputStream();

    to show the web page itself on mobile screen.

    let give u example:
    when i need to show my location on google map , i send my long./lat. to goolge in url , then

    i read byte array then consist image from previous byte[]
    ok

    what should i do to show the web page itself on mobile screen ,in case http://forum.nokia.com as example ?

    Thanks in advance
    Nabil

  5. #5
    Super Contributor
    Join Date
    Mar 2003
    Location
    Finland
    Posts
    9,560

    Re: How to open web page from Midlet

    You can launch an external browser instance with a platformRequest call.

    However, if you want to show the web page inside your MIDlet, then you need to write your own browser (parse the HTML/CSS/JavaScript yourself, and write your own rendering engine to display it, too).

  6. #6
    Super Contributor
    Join Date
    Mar 2008
    Location
    The Capital of INDIA
    Posts
    4,328

    Thumbs up Re: How to open web page from Midlet

    Hi,
    try this


    inputStream = connection.openInputStream ();
    contentLength = ( int )connection.getLength ();
    if (contentLength!=-1)
    {
    for (int i = 0; i < contentLength; i++)
    {
    if ( ( intForReadInputStream = inputStream.read () ) != -1 )
    {
    if (intForReadInputStream <= ' ')
    {
    intForReadInputStream = ' ';
    }
    buffer.append ((char) intForReadInputStream);
    }
    }
    strReturned = buffer.toString ();
    Thanks with Regards,

    R a j - The K e r n e l


    Join Delhi-NCR Nokia Developer's Community,

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

    Re: How to open web page from Midlet

    Nabil_java, I think petrib's answer is the most suitable for you or your use case...
    Use platformRequest and use the phone browser to display the page.

    Hartti

Similar Threads

  1. Replies: 11
    Last Post: 2008-03-08, 18:07
  2. problem in accessing a web page..
    By Nitin SuperByte in forum Symbian Networking & Messaging (Closed)
    Replies: 4
    Last Post: 2007-09-02, 11:19
  3. Show text as link to web page
    By Svat_ in forum Symbian
    Replies: 2
    Last Post: 2007-08-03, 22:37
  4. Is possible to call another page from one midlet
    By Gnanasekarcm in forum Mobile Java General
    Replies: 0
    Last Post: 2005-10-19, 08:30
  5. problem in loading web page in emulator
    By kmsoomro in forum Symbian
    Replies: 0
    Last Post: 2004-06-17, 16:57

Posting Permissions

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