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

1PCS PROPORTIONAL AMPLIFIER VT-VSPA1-2-10/V0/0 REXROTH INDUSTRY PLC MODULE V4
$1271.05
1PCS PROPORTIONAL AMPLIFIER VT-VSPA1-2-10/V0/0 REXROTH INDUSTRY PLC MODULE V4 pictureHONEYWELL PLUG-IN AMPLIFIER R7247A1005 NEW 286R 4 SEC RESPONSE 97-4166 REV
$190.0
HONEYWELL  PLUG-IN AMPLIFIER   R7247A1005  NEW 286R 4 SEC RESPONSE 97-4166 REV pictureTHORDARSON 23V102 - 2 X 36V 3A TRANSFORMER SOLID STATE AMPLIFIER TRIAD UTC
$34.95
THORDARSON 23V102 - 2 X 36V 3A TRANSFORMER SOLID STATE AMPLIFIER TRIAD UTC picture200 Ea Nippon Chemi Con 180 UF 400V Snap In Capacitor Audio Tube Amplifier
$99.95
200 Ea Nippon Chemi Con 180 UF 400V Snap In Capacitor Audio Tube Amplifier pictureThurlby Thandar WA301 Wideband Amplifier DC-1 MHz 30 V P-P Output
$129.0
Thurlby Thandar WA301 Wideband Amplifier DC-1 MHz 30 V P-P Output picture






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