I need to get my current location using GPS programmatically. How can i achieve it?
I will recommend using Smart Location Library
Very simple to use and it wraps the location logic nicely.
For starting the location service:
SmartLocation.with(context).location()
.start(new OnLocationUpdatedListener() { ... });
If you just want to get a single location (not periodic) you can just use the oneFix modifier. Example:
SmartLocation.with(context).location()
.oneFix()
.start(new OnLocationUpdatedListener() { ... });