Skip to content

Instantly share code, notes, and snippets.

@shikto1
Last active January 11, 2020 12:55
Show Gist options
  • Save shikto1/53e2f33ff841feee4d03f22bde353ede to your computer and use it in GitHub Desktop.
Save shikto1/53e2f33ff841feee4d03f22bde353ede to your computer and use it in GitHub Desktop.
public class GoodActivity extends Activity implements LocationListener {
private LocationManager mLocManager;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_leaks);
mLocManager = (LocationManager) getSystemService(LOCATION_SERVICE);
mLocManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER,
TimeUnit.MINUTES.toMillis(5), 100, this);
}
@Override
protected void onDestroy() {
if(mLocManager != null){
mLocManager.removeUpdates(this);
}
super.onDestroy();
}
// Listener implementation omitted
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment