我正在尝试将BUMP API集成到我的应用中。他们网站上的相同文档不够好。我已经下载了Github上提供的名为 BumpTest 的示例,并获得了一个API密钥。我正在尝试模拟我的手机和模拟器之间的碰撞,这是与GPS打开相同的WIFI!但我在logcat中看不到任何匹配/颠簸。请帮帮我!!
private final ServiceConnection connection = new ServiceConnection() {
@Override
public void onServiceConnected(ComponentName className, IBinder binder) {
Log.i("BumpTest", "onServiceConnected");
api = IBumpAPI.Stub.asInterface(binder);
try {
api.configure("MY KEY",
"Bump User");
} catch (RemoteException e) {
Log.w("BumpTest", e);
}
bump.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
try {
api.simulateBump();
sendBroadcast(new Intent(BumpAPIIntents.BUMPED));
} catch (RemoteException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
});
Log.d("Bump Test", "Service connected");
}
@Override
public void onServiceDisconnected(ComponentName className) {
Log.d("Bump Test", "Service disconnected");
}
};
private final BroadcastReceiver receiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
final String action = intent.getAction();
try {
if (action.equals(BumpAPIIntents.DATA_RECEIVED)) {
Log.i("Bump Test", "Received data from: " + api.userIDForChannelID(intent.getLongExtra("channelID", 0)));
Log.i("Bump Test", "Data: " + new String(intent.getByteArrayExtra("data")));
} else if (action.equals(BumpAPIIntents.MATCHED)) {
long channelID = intent.getLongExtra("proposedChannelID", 0);
Log.i("Bump Test", "Matched with: " + api.userIDForChannelID(channelID));
api.confirm(channelID, true);
Log.i("Bump Test", "Confirm sent");
} else if (action.equals(BumpAPIIntents.CHANNEL_CONFIRMED)) {
long channelID = intent.getLongExtra("channelID", 0);
Log.i("Bump Test", "Channel confirmed with " + api.userIDForChannelID(channelID));
api.send(channelID, "Hello, world!".getBytes());
} else if (action.equals(BumpAPIIntents.NOT_MATCHED)) {
Log.i("Bump Test", "Not matched.");
} else if (action.equals(BumpAPIIntents.CONNECTED)) {
Log.i("Bump Test", "Connected to Bump...");
api.enableBumping();
}
} catch (RemoteException e) {}
}
};
答案 0 :(得分:0)
这是我的坏事。我的API密钥错了,我得到了一个正确的,它现在正在连接。但是我在iPhone上有一个类似的应用程序使用相同的API密钥,但没有与我的Android版本配对,错误消息是“找不到匹配”。 如果我们使用相同的API密钥,Bump API会根据其文档支持跨平台连接。感谢你的帮助。