このコードで携帯電話を取得longitude
したい:latitude
public void commandAction(Command com, Displayable d) {
if (com == position)
{
try
{
Criteria cr = new Criteria();
cr.setHorizontalAccuracy(500);
LocationProvider lp = LocationProvider.getInstance(cr);
// get the location, one minute timeout
Location l = lp.getLocation(60);
Coordinates coords = l.getQualifiedCoordinates();
if (coords != null)
{
double longitude = coords.getLongitude();
double latitude = coords.getLatitude();
String sLong = String.valueOf(longitude);
String sLat = String.valueOf(latitude);
Tlongitude.setString(sLong);
Tlatitude.setString(sLat);
}
} catch (LocationException ex) {
Tlongitude.setString("LocationException");
Tlatitude.setString("LocationException");
} catch (InterruptedException ex) {
Tlongitude.setString("InterruptedException");
Tlatitude.setString("InterruptedException");
}
}
}
問題は、「位置」コマンドをクリックすると、次のようなシステム アラートが表示されることですjava.lang.SecurityException : Application not authorized to access the restricted API
。
それで、私は何をすべきですか?