BordeauxServicepublic class BordeauxService extends android.app.Service Machine Learning service that runs in a remote process.
The application doesn't use this class directly. |
Fields Summary |
---|
private final String | TAG | final android.os.RemoteCallbackList | mCallbacksThis is a list of callbacks that have been registered with the
service.
It's a place holder for future communications with all registered
clients. | int | mValue | android.app.NotificationManager | mNotificationManager | BordeauxSessionManager | mSessionManager | AggregatorManager | mAggregatorManager | TimeStatsAggregator | mTimeStatsAggregator | LocationStatsAggregator | mLocationStatsAggregator | MotionStatsAggregator | mMotionStatsAggregator | private final IBordeauxService.Stub | mBinder |
Methods Summary |
---|
public android.os.IBinder | onBind(android.content.Intent intent)
// Return the requested interface.
if (IBordeauxService.class.getName().equals(intent.getAction())) {
return mBinder;
}
return null;
| public void | onCreate()
Log.i(TAG, "Bordeaux service created.");
//mNotificationManager = (NotificationManager)getSystemService(NOTIFICATION_SERVICE);
mSessionManager = new BordeauxSessionManager(this);
mMotionStatsAggregator = new MotionStatsAggregator();
mLocationStatsAggregator = new LocationStatsAggregator(this);
mTimeStatsAggregator = new TimeStatsAggregator();
mAggregatorManager = AggregatorManager.getInstance();
mAggregatorManager.registerAggregator(mMotionStatsAggregator, mAggregatorManager);
mAggregatorManager.registerAggregator(mLocationStatsAggregator, mAggregatorManager);
mAggregatorManager.registerAggregator(mTimeStatsAggregator, mAggregatorManager);
// Display a notification about us starting.
// TODO: don't display the notification after the service is
// automatically started by the system, currently it's useful for
// debugging.
showNotification();
| public void | onDestroy()
// Save the sessions
mSessionManager.saveSessions();
// Cancel the persistent notification.
//mNotificationManager.cancel(R.string.remote_service_started);
// Tell the user we stopped.
//Toast.makeText(this, R.string.remote_service_stopped, Toast.LENGTH_SHORT).show();
// Unregister all callbacks.
mCallbacks.kill();
mLocationStatsAggregator.release();
Log.i(TAG, "Bordeaux service stopped.");
| public void | onTaskRemoved(android.content.Intent rootIntent)
Toast.makeText(this, "Task removed: " + rootIntent, Toast.LENGTH_LONG).show();
| private void | showNotification()Show a notification while this service is running.
TODO: remove the code after production (when service is loaded
automatically by the system).
/*// In this sample, we'll use the same text for the ticker and the expanded notification
CharSequence text = getText(R.string.remote_service_started);
// The PendingIntent to launch our activity if the user selects this notification
PendingIntent contentIntent =
PendingIntent.getActivity(this, 0,
new Intent("android.bordeaux.DEBUG_CONTROLLER"), 0);
// // Set the info for the views that show in the notification panel.
Notification.Builder builder = new Notification.Builder(this);
builder.setSmallIcon(R.drawable.ic_bordeaux);
builder.setWhen(System.currentTimeMillis());
builder.setTicker(text);
builder.setContentTitle(text);
builder.setContentIntent(contentIntent);
Notification notification = builder.getNotification();
// Send the notification.
// We use a string id because it is a unique number. We use it later to cancel.
mNotificationManager.notify(R.string.remote_service_started, notification); */
|
|