android - Finding my current Position in Java -


i've never used android packages before, , want current position. after looking online bit, i've gotten far.

import android.location.location; import android.location.locationmanager;  import android.content.*;  public class curposgetter{  public static double[] getposition(){     locationmanager lm = (locationmanager)getsystemservice(context.location_service);      location location = (location) lm.getlastknownlocation(locationmanager.gps_provider);     double longitude = location.getlongitude();     double latitude = location.getlatitude();     double[] ans = new double[2];     ans[0] = latitude;     ans[1] = longitude;     return ans; }  public static void main (string [] args){     double[] pos = getposition();     system.out.println(pos[0] + " , " + pos[1]); }  } 

the problem @ 'getsystemservice' line: reading javadocs context understand calling method in conjunction context.location_service can current position, don't understand how call getsystemservice. appreciated, i'm sure simple issue , don't understand classes i'm using.

getsystemservice() method of context class. class not subclass context. use getsystemservice() in activity (which is subclass of context).


Comments

Popular posts from this blog

monitor web browser programmatically in Android? -

Shrink a YouTube video to responsive width -

wpf - PdfWriter.GetInstance throws System.NullReferenceException -