Skip to content

Java Help Fast

Featured Replies

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?

 

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.