public override int onStartCommand(Intent intent, int flags, int startId) { base.onStartCommand(intent, flags, startId); // intent should be created with // getShowIntent(), getHideIntent(), getCloseIntent() if (intent != null) { string action = intent.getAction(); int id = intent.getIntExtra("id", DEFAULT_ID); // this will interfere with getPersistentNotification() if (id == ONGOING_NOTIFICATION_ID) { throw new System.Exception( "ID cannot equals StandOutWindow.ONGOING_NOTIFICATION_ID"); } if (ACTION_SHOW == action || ACTION_RESTORE == action) { show(id); } else if (ACTION_HIDE == action) { hide(id); } else if (ACTION_CLOSE == action) { close(id); } else if (ACTION_CLOSE_ALL == action) { closeAll(); } else if (ACTION_SEND_DATA == action) { if (!isExistingId(id) && id != DISREGARD_ID) { //Log.w(TAG, // "Sending data to non-existant window. If this is not intended, make sure toId is either an existing window's id or DISREGARD_ID."); } Bundle data = intent.getBundleExtra(XStandOutWindow_data); int requestCode = intent.getIntExtra("requestCode", 0); //@SuppressWarnings("unchecked") Class fromCls = (Class)intent.getSerializableExtra(XStandOutWindow_fromCls); int fromId = intent.getIntExtra("fromId", DEFAULT_ID); onReceiveData(id, requestCode, data, fromCls, fromId); } } else { //Log.w(TAG, "Tried to onStartCommand() with a null intent."); } // the service is started in foreground in show() // so we don't expect Android to kill this service return START_NOT_STICKY; }