public void setMode ( ArrayList < Long > tokens , String mode ) { JSONObject jobj = new JSONObject ( ) ; try { // int a[] = {256265, 408065, 779521, 738561, 177665, 25601}; JSONArray list = new JSONArray ( ) ; JSONArray listMain = new JSONArray ( ) ; listMain . put ( 0 , mode ) ; for ( int i = 0 ; i < tokens . size ( ) ; i ++ ) { list . put ( i , tokens . get ( i ) ) ; } listMain . put ( 1 , list ) ; jobj . put ( "a" , mSetMode ) ; jobj . put ( "v" , listMain ) ; for ( int i = 0 ; i < tokens . size ( ) ; i ++ ) { modeMap . put ( tokens . get ( i ) , mode ) ; } } catch ( JSONException e ) { e . printStackTrace ( ) ; } if ( ws != null ) { ws . sendText ( jobj . toString ( ) ) ; } }
Setting different modes for an arraylist of tokens .