我收到一个找不到符号方法open(java.lang.String)错误。我不知道我是否出错了。公共连接连接器;
我收到一条找不到符号方法open(java.lang.String)错误消息。我不知道我是不是做错了。整个程序运行良好。我只有一个错误。这是一个项目,它需要在2天内提交。我希望你能尽快回答我我收到一个找不到符号方法open(java.lang.String)错误。我不知道我是否出错了。公共连接连接器;,java,android,android-bluetooth,Java,Android,Android Bluetooth,我收到一条找不到符号方法open(java.lang.String)错误消息。我不知道我是不是做错了。整个程序运行良好。我只有一个错误。这是一个项目,它需要在2天内提交。我希望你能尽快回答我 import javax.microedition.midlet.*; import javax.microedition.lcdui.*; import java.io.*; import javax.microedition.io.*; public class DeviceON extends MI
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
import java.io.*;
import javax.microedition.io.*;
public class DeviceON extends MIDlet implements CommandListener {
private Command exitCommand; // The exit command
private Display display; // The display for this MIDlet
public String btConnectionURL ;
public OutputStream out ;
private Form mainForm;
private Alert conf ;
private Command tryagainCommand ;
public StreamConnection Connector;
public interface StreamConnection{}
public DeviceON() {
display = Display.getDisplay(this);
conf = new Alert("Sucessfull","Device is ON.\n\nDevice Control",null,AlertType.CONFIRMATION);
exitCommand = new Command("Exit", Command.EXIT, 0);
tryagainCommand = new Command("Try Again",Command.OK,1);
}
public void startApp() {
try{
mainForm = new Form ("Bluetooth Device Control");
btConnectionURL = "btspp://" + "0019A40244C5" + ":1;authenticate=true;encrypt=false;master=false";
StreamConnection connection = (StreamConnection)Connector.open(btConnectionURL);
out = connection.openOutputStream();
out.write(170);
out.write(1) ;
out.flush() ;
conf.setTimeout(4000);
display.setCurrent(conf, mainForm);
try {
Thread.sleep(4000);
} catch (Exception e) {}
destroyApp(false);
notifyDestroyed();
}
catch (IOException ioe) {
mainForm = new Form ("Bluetooth Device Control");
ioe.printStackTrace();
mainForm = new Form ("Bluetooth Device Control");
mainForm.append("Connection Failed");
mainForm.addCommand(tryagainCommand) ;
mainForm.addCommand(exitCommand);
display.setCurrent(mainForm);
mainForm.setCommandListener(this);
}
}
public void pauseApp() {
}
public void destroyApp(boolean unconditional) {
}
public void commandAction(Command c, Displayable s) {
if (c == exitCommand) {
destroyApp(false);
notifyDestroyed();
}
else {
if (c == tryagainCommand)
startApp() ;
}
}
}
而不是
(StreamConnection)Connector.open(btConnectionURL);
做
在调用方法之前强制转换连接器现在我得到一个错误,说“预期!”@JClassic@PavithreeBShetty如果去掉公共接口呢StreamConnection@PavithreeBShetty上面写着什么?
((StreamConnection)Connector).open(btConnectionURL);