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
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
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
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,
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
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).
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,
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