From ac7633d8149a28af288ac0b850850cef9b13c151 Mon Sep 17 00:00:00 2001 From: sjtufs Date: Sun, 25 Aug 2013 15:45:55 +0800 Subject: This is alpha --- .../gpstracking/AndroidGPSTrackingActivity.java | 50 ++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 misc/client/gps-demo/AndroidGPSTracking/src/com/example/gpstracking/AndroidGPSTrackingActivity.java (limited to 'misc/client/gps-demo/AndroidGPSTracking/src/com/example/gpstracking/AndroidGPSTrackingActivity.java') diff --git a/misc/client/gps-demo/AndroidGPSTracking/src/com/example/gpstracking/AndroidGPSTrackingActivity.java b/misc/client/gps-demo/AndroidGPSTracking/src/com/example/gpstracking/AndroidGPSTrackingActivity.java new file mode 100644 index 0000000..cdc1413 --- /dev/null +++ b/misc/client/gps-demo/AndroidGPSTracking/src/com/example/gpstracking/AndroidGPSTrackingActivity.java @@ -0,0 +1,50 @@ +package com.example.gpstracking; + +import android.app.Activity; +import android.os.Bundle; +import android.view.View; +import android.widget.Button; +import android.widget.Toast; + +public class AndroidGPSTrackingActivity extends Activity { + + Button btnShowLocation; + + // GPSTracker class + GPSTracker gps; + + @Override + public void onCreate(Bundle savedInstanceState) { + + super.onCreate(savedInstanceState); + setContentView(R.layout.main); + + btnShowLocation = (Button) findViewById(R.id.btnShowLocation); + + // show location button click event + btnShowLocation.setOnClickListener(new View.OnClickListener() { + + @Override + public void onClick(View arg0) { + // create class object + gps = new GPSTracker(AndroidGPSTrackingActivity.this); + + // check if GPS enabled + if(gps.canGetLocation()){ + + double latitude = gps.getLatitude(); + double longitude = gps.getLongitude(); + + Toast.makeText(getApplicationContext(), "Your Location is - \nLat: " + latitude + "\nLong: " + longitude, Toast.LENGTH_LONG).show(); + }else{ + // can't get location + // GPS or Network is not enabled + // Ask user to enable GPS/network in settings + gps.showSettingsAlert(); + } + + } + }); + } + +} \ No newline at end of file -- cgit v1.2.3-70-g09d2