Code example for InvocationTargetException

Methods: getCause

        try { 
            sMethodRegisterMediaButtonEventReceiver.invoke(audioManager, receiver);
        } catch (InvocationTargetException e) {
            // Unpack original exception when possible 
            Throwable cause = e.getCause();
            if (cause instanceof RuntimeException) {
                throw (RuntimeException) cause;
            } else if (cause instanceof Error) {
                throw (Error) cause;
            } else { 
                // Unexpected checked exception; wrap and re-throw 
                throw new RuntimeException(e);
        } catch (IllegalAccessException e) {
            Log.e(TAG, "IllegalAccessException invoking registerMediaButtonEventReceiver.");
Stop searching for code, let great code find you!  Add Codota to your java IDE