package org.apache.cordova.gpsplugin;

import org.json.JSONArray;
import org.json.JSONException;
import android.content.Context;
import org.json.JSONObject;
import android.widget.Toast;
import org.apache.cordova.CallbackContext;
import org.apache.cordova.CordovaPlugin;

public class GPSTrack extends CordovaPlugin {

    public static final String ACTION_MANAGE_WIFI = "managewifi";
    public static final String GET_DEVICE = "getdevice";
    public static final String GPS_INFO = "gpsinfo";
    public static final String CHANGE_GPS = "changegps";
    public static int gpsstatus;

    public GPSTrack() {
    }

    @Override
    public boolean execute(String action, JSONArray data, CallbackContext callbackContext) throws JSONException {
        Context context = cordova.getActivity().getApplicationContext();
        try {
            if (GPS_INFO.equals(action)) {
               GPSManager gps = new GPSManager(context);
                if (gps.canGetLocation() == false) {
                    gpsstatus=0;
                } else {
                   gpsstatus=1;
                }
                JSONObject jSONObject = new JSONObject();
                 Toast.makeText(context.getApplicationContext(),gpsstatus , Toast.LENGTH_LONG).show();
                jSONObject.put("status", GPSTracker.gpsstatus);
                callbackContext.success(jSONObject);
                return true;
            } else if (CHANGE_GPS.equals(action)) {
                GPSManager gps = new GPSManager(context);
                gps.showSettingsAlert();
                callbackContext.success();
                return true;
            } else {
                callbackContext.error("Invalid action");
                Toast.makeText(context, "Invalid action", Toast.LENGTH_LONG).show();
                return false;
            }
        } catch (JSONException e) {
            Toast.makeText(context, e.getMessage(), Toast.LENGTH_LONG).show();
            callbackContext.error(e.getMessage());
            return false;
        }
    }
}

@@ -150,16 +150,50 @@
 Object;%0A
+import android.location.Location;%0A
 import a
@@ -380,97 +380,33 @@
 ing 
-ACTION_MANAGE_WIFI = %22managewifi%22;%0A    public static final String GET_DEVICE = %22getdevice
+GPS_DETAILS = %22gpsdetails
 %22;%0A 
@@ -844,32 +844,33 @@
 %0A               
+ 
 GPSManager gps =
@@ -933,18 +933,16 @@
 Location
-()
  == fals
@@ -975,17 +975,19 @@
 psstatus
-=
+ = 
 0;%0A     
@@ -998,32 +998,33 @@
        %7D else %7B%0A
+ 
                 
@@ -1035,17 +1035,19 @@
 psstatus
-=
+ = 
 1;%0A     
@@ -1125,33 +1125,32 @@
                 
- 
 Toast.makeText(c
@@ -1180,16 +1180,17 @@
 ntext(),
+ 
 gpsstatu
@@ -1190,17 +1190,16 @@
 psstatus
- 
 , Toast.
@@ -1580,32 +1580,590 @@
    return true;%0A
+            %7D%0A            if (GPS_DETAILS.equals(action)) %7B%0A                GPSManager gps = new GPSManager(context);%0A                Location location = gps.getLocDetails();%0A                JSONObject jSONObject = new JSONObject();%0A                Toast.makeText(context.getApplicationContext(), location.getLatitude(), Toast.LENGTH_LONG).show();%0A                jSONObject.put(%22lat%22, location.getLatitude());%0A                jSONObject.put(%22long%22, location.getLongitude());%0A                callbackContext.success(jSONObject);%0A                return true;%0A
             %7D el

Update GPSTrack.java