BlackBerry Forums Support Community
              

Closed Thread
 
LinkBack Thread Tools
Old 04-04-2008, 01:04 PM   #1 (permalink)
New Member
 
Join Date: Mar 2008
Model: 8820
PIN: N/A
Carrier: Airtel
Posts: 5
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default HttpConnection problem using midlet

Please Login to Remove!

Hi,
I am using standard midlet code which i run on Motorola and Nokia devices. The application is working fine on actual device but i can not connect to the server using HttpConnection GCF.

Here is the sample of code which is running perfectly on emulator but displaying error on device and i am unable to eastablish the connection.

Please guide me.

Thanks
Shailesh

---------------
Code:


import java.io.InputStream;
import javax.microedition.io.Connector;
import javax.microedition.io.HttpConnection;
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;

public class TestMidlet extends MIDlet implements Runnable,CommandListener
{
private Thread thread;
Display display;
Form frm=new Form("Response");
Command cmd=new Command("Exit",Command.OK,0);
public void startApp ()
{
display=Display.getDisplay(this);
frm.addCommand(cmd);
frm.setCommandListener(this);
display.setCurrent(frm);
try
{
thread = new Thread (this);
thread.start ();
}
catch(Exception e)
{
System.out.println(">>> Exception Caught : " + e.toString ());
}
finally
{
System.out.println("-- startApp() : end -- ");
}
}


public void commandAction(Command c,Displayable d)
{
if(c==cmd){
this.notifyDestroyed();
}
}
public void pauseApp ()
{
}

public void destroyApp (boolean unconditional)
{
}
StringBuffer str=new StringBuffer();
public void run ()
{
try
{
HttpConnection con = (HttpConnection) Connector.open("http://www.google.com");
frm.append("Tryig to Connect..");
InputStream is = con.openInputStream();
frm.append("\n\nNow Connecting..");
int c = 0;
while ((c = is.read()) != -1)
{
str.append((char) c);
}
frm.append("\n\n Connected: "+str);
display.setCurrent(frm);
is.close();
con.close();
}
catch(Exception e)
{
frm.append("\n\nException :" + e.toString());
}
finally
{
System.out.println("-- run() : end -- ");
}
}

}
Offline  
Closed Thread


Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

PARKER D1VW20HJWF 70 SOLENOID VALVE 24VDC
$150.0
PARKER D1VW20HJWF   70  SOLENOID VALVE  24VDC pictureBELIMO SWISS AF24 SOLENOID VALVE CONTROL AS IS &TD-1
$69.0
BELIMO SWISS AF24 SOLENOID VALVE CONTROL AS IS &TD-1 pictureNEW, WHITE RODGERS 25D46A-344 SOLENOID GAS VALVE 25D46A344
$0.99
NEW, WHITE RODGERS 25D46A-344 SOLENOID GAS VALVE 25D46A344 pictureParker 04F20C2210ACFPH040 Solenoid Shutoff Valve 1/4" NPT, 5/32 Orifice
$49.95
Parker 04F20C2210ACFPH040 Solenoid Shutoff Valve 1/41PC New in bag SMC solenoid valve VK334-5G #0H08
$59.87
1PC New in bag SMC solenoid valve VK334-5G #0H08 picture






Copyright 2004-2016 BlackBerryForums.com.
The names RIM and BlackBerry are registered Trademarks of BlackBerry Inc.