剛開始使用Android開發時,我想在Android Studio的新項目中使用Android Websockets代碼。將模塊導入Android Studio
OS X 10.8.x,AS 0.4.0
我也跟着:How to import eclipse library project from github to android studio project?
一切偉大的工作,直到我試圖實際上代碼。我粘貼在(從示例):
List<BasicNameValuePair> extraHeaders = Arrays.asList(
new BasicNameValuePair("Cookie", "session=abcd")
);
WebSocketClient client = new WebSocketClient(URI.create("wss://irccloud.com"), new WebSocketClient.Listener() {
@Override
public void onConnect() {
Log.d(TAG, "Connected!");
}
@Override
public void onMessage(String message) {
Log.d(TAG, String.format("Got string message! %s", message));
}
@Override
public void onMessage(byte[] data) {
Log.d(TAG, String.format("Got binary message! %s", toHexString(data)));
}
@Override
public void onDisconnect(int code, String reason) {
Log.d(TAG, String.format("Disconnected! Code: %d Reason: %s", code, reason));
}
@Override
public void onError(Exception error) {
Log.e(TAG, "Error!", error);
}
}, extraHeaders);
client.connect();
// Later…
client.send("hello!");
client.send(new byte[] { 0xDE, 0xAD, 0xBE, 0xEF });
client.disconnect();
當我建立/運行該項目,我得到:
error: cannot find symbol class WebSocketClient
我想我的問題是:什麼是import
聲明我應該使用?
我將如何去添加/使用此代碼?