Created
December 1, 2017 01:58
-
-
Save daeun1012/3e35341b45011f7794188cb057a2b340 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MyLocationListener { | |
public MyLocationListener(Context context, Callback callback) { | |
// ... | |
} | |
void start() { | |
// connect to system location service | |
} | |
void stop() { | |
// disconnect from system location service | |
} | |
} | |
class MyActivity extends AppCompatActivity { | |
private MyLocationListener myLocationListener; | |
@Override | |
public void onCreate(...) { | |
myLocationListener = new MyLocationListener(this, (location) -> { | |
// update UI | |
}); | |
} | |
@Override | |
public void onStart() { | |
super.onStart(); | |
myLocationListener.start(); | |
// manage other components that need to respond | |
// to the activity lifecycle | |
} | |
@Override | |
public void onStop() { | |
super.onStop(); | |
myLocationListener.stop(); | |
// manage other components that need to respond | |
// to the activity lifecycle | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment