Skip to content

Commit

Permalink
Update for OpenXC Android library v6.0.0.
Browse files Browse the repository at this point in the history
Only two changes, addListener and removeListener no longer throw any
exceptions UnrecognizedMeasurementTypeException anymore.
  • Loading branch information
peplin committed Nov 1, 2014
1 parent 721bc3c commit 72aae8a
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 20 deletions.
16 changes: 12 additions & 4 deletions README.mkd
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
OpenXCStarter
==============

This is a simple "hello world" project. Follow the OpenXC getting started app
[tutorial](http://openxcplatform.com/getting-started/tutorial.html) to learn
more about what this code does. You can also use this project to jumpstart your
own OpenXC app.
This is a simple "hello world" project using OpenXC. Follow the OpenXC getting
started app [tutorial](http://openxcplatform.com/getting-started/tutorial.html)
to learn more about what this code does. You can also use this project to
jumpstart your own OpenXC app.

This version of the project requires v6.0.0 or later of the OpenXC Android
library.

## License

Copyright (c) 2011-2013 Ford Motor Company
Licensed under the BSD license.
25 changes: 9 additions & 16 deletions src/com/openxc/openxcstarter/StarterActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,10 @@ public void onPause() {
// sure to unbind from the service to avoid leaking memory
if(mVehicleManager != null) {
Log.i(TAG, "Unbinding from Vehicle Manager");
try {
// Remember to remove your listeners, in typical Android
// fashion.
mVehicleManager.removeListener(EngineSpeed.class, mSpeedListener);
} catch (VehicleServiceException e) {
e.printStackTrace();
}
// Remember to remove your listeners, in typical Android
// fashion.
mVehicleManager.removeListener(EngineSpeed.class,
mSpeedListener);
unbindService(mConnection);
mVehicleManager = null;
}
Expand Down Expand Up @@ -89,8 +86,10 @@ public void run() {
};

private ServiceConnection mConnection = new ServiceConnection() {
// Called when the connection with the VehicleManager service is established, i.e. bound.
public void onServiceConnected(ComponentName className, IBinder service) {
// Called when the connection with the VehicleManager service is
// established, i.e. bound.
public void onServiceConnected(ComponentName className,
IBinder service) {
Log.i(TAG, "Bound to VehicleManager");
// When the VehicleManager starts up, we store a reference to it
// here in "mVehicleManager" so we can call functions on it
Expand All @@ -102,13 +101,7 @@ public void onServiceConnected(ComponentName className, IBinder service) {
// have an EngineSpeed.Listener (see above, mSpeedListener) and here
// we request that the VehicleManager call its receive() method
// whenever the EngineSpeed changes
try {
mVehicleManager.addListener(EngineSpeed.class, mSpeedListener);
} catch (VehicleServiceException e) {
e.printStackTrace();
} catch (UnrecognizedMeasurementTypeException e) {
e.printStackTrace();
}
mVehicleManager.addListener(EngineSpeed.class, mSpeedListener);
}

// Called when the connection with the service disconnects unexpectedly
Expand Down

0 comments on commit 72aae8a

Please sign in to comment.