Search code examples
javawindowsgeolocationwindows-rt

access gps location from java on windows


I'm trying to retrieve the most accurate geolocation of a user, which is using a java app and i haven't found anyway to access the location property, i've seen apps on the store doing it but i want to do it from a java app

what i have tried is creating a UWP class lib with visual studio and putting static methods inside, and then i thought of using jni4net to invoke it from java but i wasn't able to compile the dll

isn't there anyway to interact with the windows runtime from java, and how would i access the gps location by any other way


Solution

  • after lots of researches, i have found something that answers my needs but is not a perfect solution.

    i have created a C# console app and had it retrieves the geolocation using the System.Device.Location API and prints it to the console, and then compiled it into an exe and packed the exe with my libs.

    the java app runs the exe and gets its output and uses it as it pleases, the only problem is that the C# console app can't enable the lcoation so if the location is off the user will have to enable it manually, i hope this approach helps someone.