Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

client gps implementation

  • Loading branch information...
commit 81be0d40984420d2dc1cc557066e070d9ee7e3e9 1 parent 7b3a4a5
src authored
View
16 client/AndroidManifest.xml
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionCode="1" android:versionName="1.0" package="">
+ <uses-sdk android:minSdkVersion="7"/>
+ <application android:debuggable="true" android:icon="@drawable/icon" android:label="">
+ <activity android:name="">
+ <intent-filter>
+ <action android:name="android.intent.action.MAIN"/>
+ <category android:name="android.intent.category.LAUNCHER"/>
+ </intent-filter>
+ </activity>
+ </application>
+ <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
+ <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
+ <uses-permission android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS"/>
+ <uses-permission android:name="android.permission.INTERNET"/>
+</manifest>
View
1  client/AndroidManifest.xml~
@@ -0,0 +1 @@
+<?xml version="1.0" encoding="UTF-8"?>
View
34 client/client.pde
@@ -1 +1,35 @@
+String[] fontList;
+PFont androidFont;
+void setup() {
+ size(screenWidth, screenHeight);
+ background(0);
+ fontList = PFont.list();
+ androidFont = createFont(fontList[5], 35, true);
+ textFont(androidFont);
+}
+
+void draw() {
+ background(0);
+ // Display current GPS data
+ text("Latitude: "+currentLatitude, 20, 40);
+ text("Longitude: "+currentLongitude, 20, 75);
+ text("Accuracy: "+currentAccuracy, 20, 110);
+ text("Provider: "+currentProvider, 20, 145);
+}
+
+//-----------------------------------------------------------------------------------------
+
+void onResume() {
+ super.onResume();
+ // Build Listener
+ locationListener = new MyLocationListener();
+ // Acquire a reference to the system Location Manager
+ locationManager = (LocationManager)getSystemService(Context.LOCATION_SERVICE);
+ // Register the listener with the Location Manager to receive location updates
+ locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, locationListener);
+}
+
+void onPause() {
+ super.onPause();
+}
View
BIN  client/code/oscP5.jar
Binary file not shown
View
51 client/gps.pde
@@ -0,0 +1,51 @@
+// Imports
+import android.content.Context;
+import android.location.Location;
+import android.location.LocationManager;
+import android.location.LocationListener;
+import android.location.GpsStatus.Listener;
+import android.location.GpsStatus.NmeaListener; // not needed yet, but going for nmea data next!
+import android.os.Bundle;
+
+LocationManager locationManager;
+MyLocationListener locationListener;
+
+// Variables to hold the current GPS data
+float currentLatitude = 0;
+float currentLongitude = 0;
+float currentAccuracy = 0;
+String currentProvider = "";
+
+//-----------------------------------------------------------------------------------------
+
+
+
+//-----------------------------------------------------------------------------------------
+
+
+
+//-----------------------------------------------------------------------------------------
+
+// Define a listener that responds to location updates
+class MyLocationListener implements LocationListener {
+ void onLocationChanged(Location location) {
+ // Called when a new location is found by the network location provider.
+ currentLatitude = (float)location.getLatitude();
+ currentLongitude = (float)location.getLongitude();
+ currentAccuracy = (float)location.getAccuracy();
+ currentProvider = location.getProvider();
+ }
+ void onProviderDisabled (String provider) {
+ currentProvider = "";
+ }
+
+ void onProviderEnabled (String provider) {
+ currentProvider = provider;
+ }
+
+ void onStatusChanged (String provider, int status, Bundle extras) {
+ // Nothing yet...
+ }
+
+}
+
View
0  client/osc.pde
No changes.
View
1  client/sketch.properties
@@ -0,0 +1 @@
+mode=Android
Please sign in to comment.
Something went wrong with that request. Please try again.