app/src/main/java/com/find/wifitool/wifi/WifiIntentReceiver.java
private void sendPayload(String event, String serverName, JSONObject json) {


        Log.d(TAG, "gh");
        if(event.equalsIgnoreCase("track")) {
            Callback postTrackEvent = new Callback() {
                @Override
                public void onFailure(Request request, IOException e) {
                    Log.e(TAG, "Failed request: " + request, e);
                }

                @Override
                public void onResponse(Response response) throws IOException {
                    String body = response.body().string();
                    if (response.isSuccessful()) {
                        Log.d(TAG, body);
                        try {
                            JSONObject json = new JSONObject(body);
                            currLocation = json.getString("location").toUpperCase();
                            JSONObject object= json.getJSONObject("rf");

                            object.names().getString(0);
                            object.toJSONArray(object.names()).getString(0);
                            Log.d("JSON array"," "+object.toJSONArray(object.names()).getString(0));


                        } catch (JSONException e) {
                            Log.e(TAG, "Failed to extract location from response: " + body, e);
                        }
                        sendCurrentLocation(currLocation);
                        //sendCurrentLocation(body);

                    } else {
                        Log.e(TAG, "Unsuccessful request: " + body);
                    }
                }
            };
            client.findTrack(postTrackEvent, serverName, json);

        } else {
            Callback postLearnEvent = new Callback() {
                @Override
                public void onFailure(Request request, IOException e) {
                    Log.e(TAG, "Failed request: " + request, e);
                }

                @Override
                public void onResponse(Response response) throws IOException {
                    String body = response.body().string();
                    Log.d(TAG, body);
                }
            };
            client.findLearn(postLearnEvent, serverName, json);

        }

    }
// Function to check to check the route(learn or track) and send data to server
Function to check to check the route(learn or track) and send data to server
Function to check to check the route ( learn or track ) and send data to server
private void sendPayload(String event, String serverName, JSONObject json) {
        Log.d(TAG, "gh");
        if(event.equalsIgnoreCase("track")) {
            Callback postTrackEvent = new Callback() {
                @Override
                public void onFailure(Request request, IOException e) {
                    Log.e(TAG, "Failed request: " + request, e);
                }
                @Override
                public void onResponse(Response response) throws IOException {
                    String body = response.body().string();
                    if (response.isSuccessful()) {
                        Log.d(TAG, body);
                        try {
                            JSONObject json = new JSONObject(body);
                            currLocation = json.getString("location").toUpperCase();
                            JSONObject object= json.getJSONObject("rf");
                            object.names().getString(0);
                            object.toJSONArray(object.names()).getString(0);
                            Log.d("JSON array"," "+object.toJSONArray(object.names()).getString(0));
                        } catch (JSONException e) {
                            Log.e(TAG, "Failed to extract location from response: " + body, e);
                        }
                        sendCurrentLocation(currLocation);
                    } else {
                        Log.e(TAG, "Unsuccessful request: " + body);
                    }
                }
            };
            client.findTrack(postTrackEvent, serverName, json);
        } else {
            Callback postLearnEvent = new Callback() {
                @Override
                public void onFailure(Request request, IOException e) {
                    Log.e(TAG, "Failed request: " + request, e);
                }
                @Override
                public void onResponse(Response response) throws IOException {
                    String body = response.body().string();
                    Log.d(TAG, body);
                }
            };
            client.findLearn(postLearnEvent, serverName, json);
        }
    }
private void sendPayload ( String event , String serverName , JSONObject json ) { Log . d ( TAG , "gh" ) ; if ( event . equalsIgnoreCase ( "track" ) ) { Callback postTrackEvent = new Callback ( ) { @ Override public void onFailure ( Request request , IOException e ) { Log . e ( TAG , "Failed request: " + request , e ) ; } @ Override public void onResponse ( Response response ) throws IOException { String body = response . body ( ) . string ( ) ; if ( response . isSuccessful ( ) ) { Log . d ( TAG , body ) ; try { JSONObject json = new JSONObject ( body ) ; currLocation = json . getString ( "location" ) . toUpperCase ( ) ; JSONObject object = json . getJSONObject ( "rf" ) ; object . names ( ) . getString ( 0 ) ; object . toJSONArray ( object . names ( ) ) . getString ( 0 ) ; Log . d ( "JSON array" , " " + object . toJSONArray ( object . names ( ) ) . getString ( 0 ) ) ; } catch ( JSONException e ) { Log . e ( TAG , "Failed to extract location from response: " + body , e ) ; } sendCurrentLocation ( currLocation ) ; } else { Log . e ( TAG , "Unsuccessful request: " + body ) ; } } } ; client . findTrack ( postTrackEvent , serverName , json ) ; } else { Callback postLearnEvent = new Callback ( ) { @ Override public void onFailure ( Request request , IOException e ) { Log . e ( TAG , "Failed request: " + request , e ) ; } @ Override public void onResponse ( Response response ) throws IOException { String body = response . body ( ) . string ( ) ; Log . d ( TAG , body ) ; } } ; client . findLearn ( postLearnEvent , serverName , json ) ; } }
Function to check to check the route(learn or track) and send data to server
Function to check to check the route ( learn or track ) and send data to server
//sendCurrentLocation(body);