I'm new to Android Studio.

I'm trying to send my current location as a text message when clicking a button but nothing happens when I click.

First, here's my XML:

```
<Button android:id="@+id/emergency"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_alignParentStart="true"
        android:layout_centerVertical="true"
        android:layout_marginLeft="14dp"
        android:layout_marginStart="14dp"
        android:background="@drawable/button_selector1"
        android:drawableEnd="@android:drawable/ic_dialog_alert"
        android:gravity="center"
        android:maxLines="1"
        android:paddingLeft="15dip"
        android:paddingRight="15dip" />

```

Then, here's my MainActivity code:

```
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    setContentView(R.layout.ly_home);

    emergency = (Button) findViewById(R.id.emergency);

    emergency.setOnClickListener(new View.OnClickListener(){
        @Override
        public void onClick(View v){
            GPStracker g = new GPStracker(getApplicationContext());
            Location l = g.getLocation();
            if (l != null){
                double lat = l.getLatitude();
                double lon = l.getLongitude();
                String message="http://maps.google.com/maps?saddr="+lat+","+lon;
                String number = "xxxxxxxx";
                SmsManager smsManager = SmsManager.getDefault();
                StringBuffer smsBody = new StringBuffer();
                smsBody.append(Uri.parse(message));
                android.telephony.SmsManager.getDefault().sendTextMessage(number, null, smsBody.toString(), null,null);
            }
        }
    });
}

```

And, my GPStracker class:

```
public class GPStracker implements LocationListener{

    Context context;
    public GPStracker(Context c){
        context = c;
    }

    public Location getLocation(){

        LocationManager lm = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE);
        boolean isGPSEnabled = lm.isProviderEnabled(LocationManager.GPS_PROVIDER);
        if (isGPSEnabled){
            lm.requestLocationUpdates(LocationManager.GPS_PROVIDER,6000,10,this);
            Location l = lm.getLastKnownLocation(LocationManager.GPS_PROVIDER);
            return l;
        }else{
            Toast.makeText(context,"Please enable GPS", Toast.LENGTH_LONG).show();
        }
        return null;
    }

    @Override
    public void onLocationChanged(Location location) {

    }

    @Override
    public void onStatusChanged(String provider, int status, Bundle extras) {

    }

    @Override
    public void onProviderEnabled(String provider) {

    }

    @Override
    public void onProviderDisabled(String provider) {

    }
}

```

I've given the permissions in the manifest: Fine location, Coarse location and receiving and sending text messages. What am I doing wrong?