Buggy code:
@ SuppressLint ( { "SetJavaScriptEnabled" } ) public class LoginManager { private static final String START_URL = "login//" ; private static final String END_URL = "login//done" ; private static final String WINDOWS_AZURE_ACTIVE_DIRECTORY_REST_API_PATH_NAME = "aad" ; private static final String TOKEN_MARK = "#token=" ; private static final String TOKEN_JSON_PARAMETER = "authenticationToken" ; private static final String USERID_JSON_PROPERTY = "userId" ; private static final String USER_JSON_PROPERTY = "user" ; private MobileServiceClient mClient ; public LoginManager ( MobileServiceClient client ) { } public ListenableFuture < MobileServiceUser > authenticate ( String provider , Context context ) { } public void authenticate ( String provider , Context context , final UserAuthenticationCallback callback ) { } public ListenableFuture < MobileServiceUser > authenticate ( String provider , String oAuthToken ) { } public void authenticate ( String provider , String oAuthToken , final UserAuthenticationCallback callback ) { } private String normalizeProvider ( String provider ) { } private void showLoginUI ( final String startUrl , final String endUrl , final Context context , final LoginManager . LoginUIOperationCallback callback ) { } private void showLoginUIInternal ( final String startUrl , final String endUrl , final Context context , LoginManager . LoginUIOperationCallback callback ) { if ( ( startUrl == null ) || ( startUrl == "" ) ) { throw new IllegalArgumentException ( "startUrl<seq2seq4repair_space>can<seq2seq4repair_space>not<seq2seq4repair_space>be<seq2seq4repair_space>null<seq2seq4repair_space>or<seq2seq4repair_space>empty" ) ; } if ( ( endUrl == null ) || ( endUrl == "" ) ) { throw new IllegalArgumentException ( "endUrl<seq2seq4repair_space>can<seq2seq4repair_space>not<seq2seq4repair_space>be<seq2seq4repair_space>null<seq2seq4repair_space>or<seq2seq4repair_space>empty" ) ; } if ( context == null ) { throw new IllegalArgumentException ( "context<seq2seq4repair_space>can<seq2seq4repair_space>not<seq2seq4repair_space>be<seq2seq4repair_space>null" ) ; } final LoginManager . LoginUIOperationCallback externalCallback = callback ; final AlertDialog . Builder builder = new AlertDialog . Builder ( context ) ; final WebView wv = new WebView ( context ) ; builder . setOnCancelListener ( new DialogInterface . OnCancelListener ( ) { @ Override public void onCancel ( DialogInterface dialog ) { if ( externalCallback != null ) { externalCallback . onCompleted ( null , new MobileServiceException ( "User<seq2seq4repair_space>Canceled" ) ) ; } } } ) ; wv . getSettings ( ) . setJavaScriptEnabled ( true ) ; DisplayMetrics displaymetrics = new DisplayMetrics ( ) ; ( ( android . app . Activity ) ( context ) ) . getWindowManager ( ) . getDefaultDisplay ( ) . getMetrics ( displaymetrics ) ; <START_BUG> int webViewHeight = displaymetrics . heightPixels ; <END_BUG> wv . setLayoutParams ( new android . view . ViewGroup . LayoutParams ( LayoutParams . MATCH_PARENT , webViewHeight ) ) ; wv . requestFocus ( FOCUS_DOWN ) ; wv . setOnTouchListener ( new View . OnTouchListener ( ) { @ Override public boolean onTouch ( View view , MotionEvent event ) { int action = event . getAction ( ) ; if ( ( action == ( MotionEvent . ACTION_DOWN ) ) || ( action == ( MotionEvent . ACTION_UP ) ) ) { if ( ! ( view . hasFocus ( ) ) ) { view . requestFocus ( ) ; } } return false ; } } ) ; LinearLayout layout = new LinearLayout ( context ) ; layout . setOrientation ( VERTICAL ) ; layout . addView ( wv ) ; EditText dummyEditText = new EditText ( context ) ; dummyEditText . setVisibility ( GONE ) ; layout . addView ( dummyEditText ) ; builder . setView ( layout ) ; final AlertDialog dialog = builder . create ( ) ; wv . setWebViewClient ( new WebViewClient ( ) { @ Override public void onPageStarted ( WebView view , String url , Bitmap favicon ) { if ( isFinalUrl ( url ) ) { if ( externalCallback != null ) { externalCallback . onCompleted ( url , null ) ; } dialog . dismiss ( ) ; } super . onPageStarted ( view , url , favicon ) ; } private boolean isFinalUrl ( String url ) { if ( url == null ) { return false ; } return url . startsWith ( endUrl ) ; } private boolean isStartUrl ( String url ) { if ( url == null ) { return false ; } return url . startsWith ( startUrl ) ; } @ Override public void onPageFinished ( WebView view , String url ) { if ( isStartUrl ( url ) ) { if ( externalCallback != null ) { externalCallback . onCompleted ( null , new MobileServiceException ( "Logging<seq2seq4repair_space>in<seq2seq4repair_space>with<seq2seq4repair_space>the<seq2seq4repair_space>selected<seq2seq4repair_space>authentication<seq2seq4repair_space>provider<seq2seq4repair_space>is<seq2seq4repair_space>not<seq2seq4repair_space>enabled" ) ) ; } dialog . dismiss ( ) ; } } } ) ; wv . loadUrl ( startUrl ) ; dialog . show ( ) ; } private MobileServiceUser createUserFromJSON ( JsonObject json ) throws MobileServiceException { } private ListenableFuture < MobileServiceUser > authenticateWithToken ( String token , String url ) { } interface LoginUIOperationCallback { void onCompleted ( String url , Exception exception ) { } } }

Fix:
int webViewHeight = ( displaymetrics . heightPixels ) - 100 ;