0

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

1 回答 1

0

这是我的错。我的 API 密钥错误,我得到了正确的,现在正在连接。但是我在 iPhone 中有一个类似的应用程序,它使用了与我的 Android 版本不配对的相同 API 密钥,错误消息是“未找到匹配项”。如果我们使用相同的 API 密钥,Bump API 根据他们的文档支持跨平台连接。感谢您在这方面的帮助。

于 2012-09-04T09:25:36.127 回答