public static void preApproveSubscriptionIfRequiredAndPossible ( Roster roster , BareJid jid ) throws NotLoggedInException , NotConnectedException , InterruptedException { if ( ! roster . isSubscriptionPreApprovalSupported ( ) ) { return ; } RosterEntry entry = roster . getEntry ( jid ) ; if ( entry == null || ( ! entry . canSeeMyPresence ( ) && ! entry . isApproved ( ) ) ) { try { roster . preApprove ( jid ) ; } catch ( FeatureNotSupportedException e ) { // Should never happen since we checked for the feature above. throw new AssertionError ( e ) ; } } }
Pre - approve the subscription if it is required and possible .