Code example for InvocationTargetException

Methods: getCause

            // Shouldn't happen, but we have to catch this 
            Log.w("ServiceCompat", "Unable to invoke method", e);
        } catch (InvocationTargetException e) {
            /* The methods we call don't throw exceptions -- in general, 
               we should throw e.getCause() */ 
            Log.w("ServiceCompat", "Method threw exception", e.getCause());
    public void startForeground(int id, Notification notification) {
        if (mStartForeground != null) {
            invokeMethod(service, mStartForeground, id, notification);
        invokeMethod(service, mSetForeground, Boolean.TRUE);
        mNM.notify(id, notification);
        notifyId = id;