From 70c4c7d3bd32910fda7335f7123441a4b9b5cbb4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Gon=C3=A7alves?= Date: Fri, 24 Jan 2014 20:20:13 +0000 Subject: [PATCH] Fixes #1 --- .../up/fe/jsvgoncalves/ssim/firstapp/MainActivity.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/org/up/fe/jsvgoncalves/ssim/firstapp/MainActivity.java b/src/org/up/fe/jsvgoncalves/ssim/firstapp/MainActivity.java index 2ca14b3..2b55c90 100644 --- a/src/org/up/fe/jsvgoncalves/ssim/firstapp/MainActivity.java +++ b/src/org/up/fe/jsvgoncalves/ssim/firstapp/MainActivity.java @@ -118,8 +118,13 @@ private void setMockLocation(String lat, String lon) { newLocation.setAltitude(0d); // Calculate the bearing with the previous location. - float bearing = previousLocation.bearingTo(newLocation); - newLocation.setBearing(bearing); + if(previousLocation != null) { + float bearing = previousLocation.bearingTo(newLocation); + newLocation.setBearing(bearing); + } else { + newLocation.setBearing(0f); + } + // Provide the new location. LocationManager locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);