We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hi, I'm making a gps app using android mode, currently tested on my xperia z. Everything is working fine, except the refresh/update rate is slow, it takes about 12sec-14sec to update my location once. I haven't try anything yet, please help me if you guys know about this thanks
my code :
import android.content.Context;
import android.location.*;
import android.os.Bundle;
LocationManager manager;
GPSLocationListener gps;
float latitude;
float longitude;
float accuracy;
String provider;
class GPSLocationListener implements LocationListener
{
void onLocationChanged( Location _loc )
{
latitude = (float) _loc.getLatitude();
longitude = (float) _loc.getLongitude();
accuracy = (float) _loc.getAccuracy();
provider = _loc.getProvider();
}
void onProviderDisabled( String _provider )
{
provider = "";
}
void onProviderEnabled( String _provider )
{
provider = _provider;
}
void onStatusChanged( String _provider, int status, Bundle xtras )
{
}
}
void setup()
{
orientation( PORTRAIT );
latitude = 0;
longitude = 0;
accuracy = 0;
provider = "";
textSize(50);
}
void draw()
{
background( 5, 10, 85 );
fill( 250, 255, 13 );
noStroke();
translate( width/2, height/2 );
String msg = "Latitude: " + latitude + "\n";
msg += "Longitude: " + longitude + "\n";
msg += "Accuracy: " + accuracy + "\n";
msg += "Provider: " + provider;
textAlign( CENTER, CENTER );
text( msg, 0, 0 );
}
void onResume()
{
super.onResume();
gps = new GPSLocationListener();
manager = (LocationManager) getSystemService( Context.LOCATION_SERVICE );
manager.requestLocationUpdates( LocationManager.NETWORK_PROVIDER,
0, 0, gps );
}
void onPause()
{
super.onPause();
}
Answers
Try this class:
i've tried but it doesn't run and with many errors, i'm just a beginner so i didn't know how to correct the error.
Try this method for using that class