Jump to content

Recommended Posts

Posted
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?

 

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...