我在我的应用程序中使用PubNub SDK for Android。我尝试订阅一个频道,但没有任何反应。
这是我连接到 pubnub 的代码:
public class MyPubnub {
private static Pubnub pubnub = null;
private static final String publishKey = "MY PUBLISH KEY";
private static final String subscribeKey = "MY SUBSCRIBER KEY";
private static final String secretKey = "MY SECRET KEY";
private MyPubnub() {
}
public static Pubnub getPubnubObject() {
if (pubnub == null) {
pubnub = new Pubnub(publishKey, subscribeKey, secretKey, null,
false);
}
return pubnub;
}
}
订阅pubnub的代码:
public void onCreate(Bundle b) {
super.onCreate(b);
initUI();
Pubnub pn = MyPubnub.getPubnubObject();
String channel = getChannelName();
Reciver reciver = new Reciver();
pn.subscribe(channel, reciver);
}
class Reciver implements Callback {
@Override
public boolean execute(Object message) {
Log.d("PUBNUB", "message received [" + message.toString() + "]");
return true;
}
}
在调试过程中,我注意到一旦我尝试运行这一行,应用程序就会冻结:(
pn.subscribe(channel, reciver);
没有任何反应,没有任何反应)。
有什么想法吗?