作者elveily (...)
看板java
标题[问题] airtime问题
时间Tue May 9 20:31:55 2006
我用书中的范例在WTK里run..确出现以下讯息
ConnectorDemo wants to send and receive data
using the network. this will use airtime and may result in charges.
is it ok to use airtime?
这要怎麽解决阿 ??
范例如下:
public ConnectorDemo() // 属性、元件、初值设定(初始化)
{
display = Display.getDisplay(this);
exitCommand = new Command("离开", Command.EXIT, 1);
connCommand = new Command("连线", Command.OK, 1);
}
public void startApp() // 程式进入点
{
showForm =new Form("HTTP 连线");
showForm.append(new String("请按「连线」键") );
showForm.addCommand(exitCommand);
showForm.addCommand(connCommand);
showForm.setCommandListener(this);
display.setCurrent(showForm);
}
public void pauseApp() { }
public void destroyApp(boolean unconditional) { }
public void commandAction(Command c, Displayable s) // 各事件处理函数
{
if(c==connCommand)
{
String showStr="";
HttpConnection httpConn = null;
try // 开启连线
{
httpConn =
(HttpConnection)Connector.open("
http://127.0.0.1:8080/index.htm");
if( httpConn.getResponseCode() == HttpConnection.HTTP_OK)
showStr = "连线成功!";
else
showStr = "连线失败!";
}
catch(Exception O)
{
showStr = O.getMessage();
}
try // 关闭连线
{
if(httpConn != null)
httpConn.close();
}
catch(Exception O)
{
showStr = O.getMessage();
}
// 将连线状态显示在 Alert 物件上
Alert alert = new Alert("连线状态", showStr, null, AlertType.INFO);
alert.setTimeout( Alert.FOREVER );
display.setCurrent( alert );
}
if(c==exitCommand)
{
destroyApp(false);
notifyDestroyed();
}
}
}
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 61.223.212.177