library add detach method, and samples add detach method on onDestroy callback