Android Tutorial For Beginners
Android Tutorial For Beginners
Android Tutorial
Android Tutorial for beginners
http://niravranpara.blogspot.com.br/2013/04/android-get-current-gps-location.html 08/10/2013
Android Tutorial : Android get current GPS location Página 2 de 12
FOLLOWERS
Android get current GPS location
Overview of location services in Android , LocationManager class at the heart of location services in
Android.
Here is one example which try to find location using GPS , if your GPS not available then try to use
network for find location
Demo Code
Activity - AndroidGPSTrackingActivity.java
Button btnShowLocation;
Submit
// GPSTracker class
GPSTracker gps;
WHAT VERSION OF ANDROID IS BEST ?
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
@Override
public void onClick(View arg0) { BEAT READ TUTORIAL LIST
// create class object
gps = new GPSTracker(AndroidGPSTrackingActivity.this); Android get current GPS location
ANDROID TUTORIAL
Android Fundamentals
Detect Battery Info.
Android Enable GPS (Check and prompt
user to enable GPS)
Android Location New Features
Android Notifications
TOP LINKS
Advance Android
Android Development Forum
Android Tutorials
Hello Android
Official Android Developers Blog
GPSTracke.java
http://niravranpara.blogspot.com.br/2013/04/android-get-current-gps-location.html 08/10/2013
Android Tutorial : Android get current GPS location Página 3 de 12
} catch (Exception e) {
e.printStackTrace();
http://niravranpara.blogspot.com.br/2013/04/android-get-current-gps-location.html 08/10/2013
Android Tutorial : Android get current GPS location Página 4 de 12
return location;
}
/**
* Stop using GPS listener
* Calling this function will stop using GPS in your app
* */
public void stopUsingGPS(){
if(locationManager != null){
locationManager.removeUpdates(GPSTracker.this);
}
}
/**
* Function to get latitude
* */
public double getLatitude(){
if(location != null){
latitude = location.getLatitude();
}
// return latitude
return latitude;
}
/**
* Function to get longitude
* */
public double getLongitude(){
if(location != null){
longitude = location.getLongitude();
}
// return longitude
return longitude;
}
/**
* Function to check GPS/wifi enabled
* @return boolean
* */
public boolean canGetLocation() {
return this.canGetLocation;
}
/**
* Function to show settings alert dialog
* On pressing Settings button will lauch Settings Options
* */
public void showSettingsAlert(){
AlertDialog.Builder alertDialog = new AlertDialog.Builder(mContext);
@Override
public void onLocationChanged(Location location) {
}
@Override
public void onProviderDisabled(String provider) {
http://niravranpara.blogspot.com.br/2013/04/android-get-current-gps-location.html 08/10/2013
Android Tutorial : Android get current GPS location Página 5 de 12
@Override
public void onProviderEnabled(String provider) {
}
@Override
public void onStatusChanged(String provider, int status, Bundle extras) {
}
@Override
public IBinder onBind(Intent arg0) {
return null;
}
Layout - main.xml
<Button android:id="@+id/btnShowLocation"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Show Location"
android:layout_centerVertical="true"
android:layout_centerHorizontal="true"/>
</RelativeLayout>
Labels: GPS
13 comments:
saludos cordiales
Consigue moviles dual sim al mejor precio
Reply
Reply
http://niravranpara.blogspot.com.br/2013/04/android-get-current-gps-location.html 08/10/2013
Android Tutorial : Android get current GPS location Página 6 de 12
Crazy that Google doesn't provide any example code with their documentation...
this worked a treat though, thanks
Reply
Publish Preview
http://niravranpara.blogspot.com.br/2013/04/android-get-current-gps-location.html 08/10/2013
Android Tutorial : Android get current GPS location Página 7 de 12
http://niravranpara.blogspot.com.br/2013/04/android-get-current-gps-location.html 08/10/2013
Android Tutorial : Android get current GPS location Página 8 de 12
http://niravranpara.blogspot.com.br/2013/04/android-get-current-gps-location.html 08/10/2013
Android Tutorial : Android get current GPS location Página 9 de 12
http://niravranpara.blogspot.com.br/2013/04/android-get-current-gps-location.html 08/10/2013
Android Tutorial : Android get current GPS location Página 10 de 12
http://niravranpara.blogspot.com.br/2013/04/android-get-current-gps-location.html 08/10/2013
Android Tutorial : Android get current GPS location Página 11 de 12
http://niravranpara.blogspot.com.br/2013/04/android-get-current-gps-location.html 08/10/2013
Android Tutorial : Android get current GPS location Página 12 de 12
http://niravranpara.blogspot.com.br/2013/04/android-get-current-gps-location.html 08/10/2013