This is an all-new version of the Bump API for Android.
The corresponding iOS API can be found here: https://github.com/bumptech/bump-api-ios/.
- Significantly faster and more reliable: this API uses Bump's third-generation platform. The previous Android API used our 1.x platform.
- multiple concurrent sessions: once two users have matched, they can continue to send data to each other and other users
- at the moment breaks compatibility with earlier versions of the API... consider using a different API key just to be safe.
- Bugfixes
- disableBumping now works
- constants provided for Intent extras
- The Bump service stops itself when completely unbound.
- README's
android update project
example corrected with additional required parameter.
A complete, working example project is contained in bump-test
.
-
Agree to the API license agreement and get your API key: http://bu.mp/apiagree
-
Run
android update
on both projects:android update project -t android-15 -p bump-api-library/; android update project -p bump-test/;
-
Bump logos and other assets are available here: http://bu.mp/company/bumpAPIinstructions . Please be aware of the trademark guidelines (http://bu.mp/company/apitrademark), to which you must agree before receiving an API key.
In your shell, run android update project -t android-15 -l path_to/bump-api-library -p path_to_your_project/
Add the Bump service to your <application>
:
<service android:name="com.bump.api.BumpAPI">
<intent-filter>
<action android:name="com.bump.api.IBumpAPI" />
</intent-filter>
</service>
Require the following permissions, if you haven't already, in your <manifest>
:
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
import com.bump.api.IBumpAPI;
import com.bump.api.BumpAPIIntents;
Create and bind your ServiceConnection
object:
private IBumpAPI api;
private final ServiceConnection connection = new ServiceConnection() {
@Override
public void onServiceConnected(ComponentName className, IBinder binder) {
api = IBumpAPI.Stub.asInterface(binder);
try {
api.configure("your_api_key", "Bump User");
} catch (RemoteException e) {}
}
};
bindService(new Intent(IBumpAPI.class.getName()),
connection,
Context.BIND_AUTO_CREATE);
Listen for and filter on Bump intents:
/* NOTE: A complete list of Intents sent, along with their Extras, is contained in bump-api-library/src/com/bump/api/IBumpAPI.aidl */
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)) {
api.confirm(intent.getLongExtra("proposedChannelID", 0), true);
} else if (action.equals(BumpAPIIntents.CHANNEL_CONFIRMED)) {
api.send(intent.getLongExtra("channelID", 0), "Hello, world!".getBytes());
} else if (action.equals(BumpAPIIntents.CONNECTED)) {
api.enableBumping();
}
} catch (RemoteException e) {}
}
};
IntentFilter filter = new IntentFilter();
filter.addAction(BumpAPIIntents.CHANNEL_CONFIRMED);
filter.addAction(BumpAPIIntents.DATA_RECEIVED);
filter.addAction(BumpAPIIntents.NOT_MATCHED);
filter.addAction(BumpAPIIntents.MATCHED);
filter.addAction(BumpAPIIntents.CONNECTED);
registerReceiver(receiver, filter);
Your app is now bumpable!
- Use of this library is subject to both our SDK License agreement, http://bu.mp/licagr_internaluse, and Trademark Guidelines: http://bu.mp/apitrademark
- This is a beta, please submit any and all comments and questions to [email protected]