@ Override protected void onPostExecute ( String result ) { super . onPostExecute ( result ) ; if ( result . equals ( "ok" ) ) { progress . dismiss ( ) ; if ( Build . VERSION . SDK_INT >= Build . VERSION_CODES . LOLLIPOP ) { mActivity . showDoneAnimation ( ) ; } else { ( ( Activity ) mContext ) . finish ( ) ; } } else if ( result . equals ( "org.eclipse.egit.github.core.client.RequestException: Bad credentials (401)" ) ) { progress . dismiss ( ) ; new AlertDialog . Builder ( mContext ) . setTitle ( "Unable to send report" ) . setMessage ( "Wrong username or password or invalid access token." ) . setPositiveButton ( "Try again" , new DialogInterface . OnClickListener ( ) { public void onClick ( DialogInterface dialog , int which ) { // do nothing } } ) . setIcon ( R . drawable . gittyreporter_ic_mood_bad_black_24dp ) . show ( ) ; } else { progress . dismiss ( ) ; new AlertDialog . Builder ( mContext ) . setTitle ( "Unable to send report" ) . setMessage ( "An unexpected error occurred. If the problem persists, contact the app developer." ) . setPositiveButton ( android . R . string . ok , new DialogInterface . OnClickListener ( ) { public void onClick ( DialogInterface dialog , int which ) { ( ( Activity ) mContext ) . finish ( ) ; } } ) . setIcon ( R . drawable . gittyreporter_ic_mood_bad_black_24dp ) . show ( ) ; } }
This runs in UI when background thread finishes