MAIN CLASS:
public final class MainActivity extends Activity { private void sendSmsWithAddress(String troubleType, LatLng coordinates, String address) { double lat = coordinates.latitude; double lng = coordinates.longitude; sendSmsToContacts(troubleType + "!\n" + address + "\nhttp://ubersafe.com/" + lat + "/" + lng); } }
NEW CLASS:
public final class TroubleRepeater { ScheduledExecutorService executor = Executors.newScheduledThreadPool(1); Runnable CoordinatesFinder = new Runnable() { public void run() { private void sendSmsWithCoordinates(String troubleType, LatLng coordinates) { double lat = coordinates.latitude; double lng = coordinates.longitude; sendSmsToContacts(troubleType + "! Coordinates:\n(" + lat + ", " + lng + ")\nhttp://ubersafe.com/" + lat + "/" + lng); } } }; ScheduledFuture result = executor.scheduleAtFixedRate(CoordinatesFinder, 2, 30, TimeUnit.SECONDS); }
I need in main class action repeat x times. I am trying to delete from main class this action and add him to new class (check my repeater, it works good or not) and i need call it in main class, how i can do it?