Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
appinventor-sources
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
xpstem
appinventor-sources
Commits
452eb6d3
Commit
452eb6d3
authored
Jan 13, 2013
by
halatmit
Committed by
Gerrit Review System
Jan 13, 2013
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix location sensor to not crash when geoserver returns empty AddressObjs list
Change-Id: I2edfdad4ed3b56519fa8d29d2e54f193c276febf
parent
74747d31
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
5 deletions
+18
-5
appinventor/components/src/com/google/appinventor/components/runtime/LocationSensor.java
...google/appinventor/components/runtime/LocationSensor.java
+18
-5
No files found.
appinventor/components/src/com/google/appinventor/components/runtime/LocationSensor.java
View file @
452eb6d3
...
...
@@ -439,9 +439,20 @@ public class LocationSensor extends AndroidNonvisibleComponent
return
sb
.
toString
();
}
}
}
catch
(
IOException
e
)
{
Log
.
e
(
"LocationSensor"
,
"Exception thrown by getFromLocation() "
+
e
.
getMessage
());
}
catch
(
Exception
e
)
{
// getFromLocation can throw an IOException or an IllegalArgumentException
// a bad result can give an indexOutOfBoundsException
// are there others?
if
(
e
instanceof
IllegalArgumentException
||
e
instanceof
IOException
||
e
instanceof
IndexOutOfBoundsException
)
{
Log
.
e
(
"LocationSensor"
,
"Exception thrown by getting current address "
+
e
.
getMessage
());
}
else
{
// what other exceptions can happen here?
Log
.
e
(
"LocationSensor"
,
"Unexpected exception thrown by getting current address "
+
e
.
getMessage
());
}
}
}
return
"No address available"
;
...
...
@@ -458,7 +469,8 @@ public class LocationSensor extends AndroidNonvisibleComponent
public
double
LatitudeFromAddress
(
String
locationName
)
{
try
{
List
<
Address
>
addressObjs
=
geocoder
.
getFromLocationName
(
locationName
,
1
);
if
(
addressObjs
==
null
)
{
Log
.
i
(
"LocationSensor"
,
"latitude addressObjs size is "
+
addressObjs
.
size
()
+
" for "
+
locationName
);
if
(
(
addressObjs
==
null
)
||
(
addressObjs
.
size
()
==
0
)
){
throw
new
IOException
(
""
);
}
return
addressObjs
.
get
(
0
).
getLatitude
();
...
...
@@ -479,7 +491,8 @@ public class LocationSensor extends AndroidNonvisibleComponent
public
double
LongitudeFromAddress
(
String
locationName
)
{
try
{
List
<
Address
>
addressObjs
=
geocoder
.
getFromLocationName
(
locationName
,
1
);
if
(
addressObjs
==
null
)
{
Log
.
i
(
"LocationSensor"
,
"longitude addressObjs size is "
+
addressObjs
.
size
()
+
" for "
+
locationName
);
if
(
(
addressObjs
==
null
)
||
(
addressObjs
.
size
()
==
0
)
){
throw
new
IOException
(
""
);
}
return
addressObjs
.
get
(
0
).
getLongitude
();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment