I am brand new to Android development. Hopefully this is an easy one. Relevant code (I hope) below.
import android.location.LocationManager;
import android.content.Context;
LocationManager locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
I get the following: Error: error: cannot find symbol method getSystemService(String)
All the code samples I am seeing say to do the above. I do notice that if I do this instead...
Context cont;
locationManager = (LocationManager) cont.getSystemService(Context.LOCATION_SERVICE);
then that particular error goes away, but of course, you have an uninstatiated variable cont. As mentioned, I am new to Android, so I don't know what a Context object is and how to get one. I've been doing a little research on that. However, all the code samples I've seen seem to be of the variety where the method getSystemService
is called without any Context object, so presumably it's compiling fine for everyone but me. Any ideas?
On a different note, the preview is coming up rather odd in the code tags. "getSystemService" is in red and crossed out, "corrected" with "get SystemService" with a space between "get" and "System". Is this a function of the code tags? This is Java code and the function is "getSystemService" with no space. Is there some auto-correct HTML parsing going on?