public void sendDrib(DribSubject subject, String message) { if (message.equals("")) { // Show error message new AlertDialog.Builder(CreateDribActivity.this) .setTitle("Error") .setMessage("Drib cannot be empty") .setPositiveButton("OK", null) .show(); } else { // Data is ok // Create new drib Location loc = GpsListener.getLocation(); final Drib newDrib = new Drib(subject, message, loc.getLatitude(), loc.getLongitude()); Log.i(TAG, "Submit new message"); // Ignoring progress dialog for now, might look better // without it - Chad // pd = new ProgressDialog(v.getContext()); // pd.setMessage("Sending Drib..."); // pd.setIndeterminate(true); // pd.setCancelable(true); // pd.show(); // Create a new Thread and send Drib Thread sendDrib = new Thread() { public void run() { // send drib DribCom.sendDrib(newDrib); // Call this method once action is complete mHandler.post(mUpdateResults); } }; sendDrib.start(); } }
public Location getCurrentLocation() { Location loc = mGps.getLocation(); if (loc == null) loc = mNetwork.getLocation(); return loc; }
// This stops the listener void stop() { mGps.stop(); mNetwork.stop(); }