我正在尝试将 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) {}
}
};