public static void unregisterRemoteControlClient( AudioManager audioManager, RemoteControlClientCompat remoteControlClient) { if (!sHasRemoteControlAPIs) { return; } try { sUnregisterRemoteControlClientMethod.invoke( audioManager, remoteControlClient.getActualRemoteControlClientObject()); } catch (Exception e) { Log.e(TAG, e.getMessage(), e); } }
static { try { ClassLoader classLoader = RemoteControlHelper.class.getClassLoader(); Class sRemoteControlClientClass = RemoteControlClientCompat.getActualRemoteControlClientClass(classLoader); sRegisterRemoteControlClientMethod = AudioManager.class.getMethod( "registerRemoteControlClient", new Class[] {sRemoteControlClientClass}); sUnregisterRemoteControlClientMethod = AudioManager.class.getMethod( "unregisterRemoteControlClient", new Class[] {sRemoteControlClientClass}); sHasRemoteControlAPIs = true; } catch (ClassNotFoundException e) { // Silently fail when running on an OS before ICS. } catch (NoSuchMethodException e) { // Silently fail when running on an OS before ICS. } catch (IllegalArgumentException e) { // Silently fail when running on an OS before ICS. } catch (SecurityException e) { // Silently fail when running on an OS before ICS. } }