Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
cordova-plugin-background-geolocation
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Aksimaya
cordova-plugin-background-geolocation
Commits
0658b684
Commit
0658b684
authored
Feb 26, 2014
by
Chris Scott
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix callbacks in Android plugin
parent
43181dc6
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
14 deletions
+23
-14
BackgroundGpsPlugin.java
src/android/BackgroundGpsPlugin.java
+23
-14
No files found.
src/android/BackgroundGpsPlugin.java
View file @
0658b684
...
...
@@ -17,6 +17,7 @@ public class BackgroundGpsPlugin extends CordovaPlugin {
public
static
final
String
ACTION_START
=
"start"
;
public
static
final
String
ACTION_STOP
=
"stop"
;
public
static
final
String
ACTION_CONFIGURE
=
"configure"
;
public
static
final
String
ACTION_SET_CONFIG
=
"setConfig"
;
private
Intent
updateServiceIntent
;
...
...
@@ -30,26 +31,31 @@ public class BackgroundGpsPlugin extends CordovaPlugin {
public
boolean
execute
(
String
action
,
JSONArray
data
,
CallbackContext
callbackContext
)
{
Activity
activity
=
this
.
cordova
.
getActivity
();
Boolean
result
=
false
;
updateServiceIntent
=
new
Intent
(
activity
,
LocationUpdateService
.
class
);
if
(
ACTION_START
.
equalsIgnoreCase
(
action
))
{
result
=
true
;
if
(
authToken
==
null
||
url
==
null
)
{
callbackContext
.
error
(
"Call configure before calling start"
);
return
false
;
}
updateServiceIntent
.
putExtra
(
"authToken"
,
authToken
);
updateServiceIntent
.
putExtra
(
"url"
,
url
);
updateServiceIntent
.
putExtra
(
"stationaryRadius"
,
stationaryRadius
);
updateServiceIntent
.
putExtra
(
"desiredAccuracy"
,
desiredAccuracy
);
updateServiceIntent
.
putExtra
(
"distanceFilter"
,
distanceFilter
);
updateServiceIntent
.
putExtra
(
"locationTimeout"
,
locationTimeout
);
updateServiceIntent
.
putExtra
(
"desiredAccuracy"
,
desiredAccuracy
);
updateServiceIntent
.
putExtra
(
"isDebugging"
,
isDebugging
);
activity
.
startService
(
updateServiceIntent
);
}
else
{
callbackContext
.
success
();
updateServiceIntent
.
putExtra
(
"authToken"
,
authToken
);
updateServiceIntent
.
putExtra
(
"url"
,
url
);
updateServiceIntent
.
putExtra
(
"stationaryRadius"
,
stationaryRadius
);
updateServiceIntent
.
putExtra
(
"desiredAccuracy"
,
desiredAccuracy
);
updateServiceIntent
.
putExtra
(
"distanceFilter"
,
distanceFilter
);
updateServiceIntent
.
putExtra
(
"locationTimeout"
,
locationTimeout
);
updateServiceIntent
.
putExtra
(
"desiredAccuracy"
,
desiredAccuracy
);
updateServiceIntent
.
putExtra
(
"isDebugging"
,
isDebugging
);
activity
.
startService
(
updateServiceIntent
);
}
}
else
if
(
ACTION_STOP
.
equalsIgnoreCase
(
action
))
{
result
=
true
;
activity
.
stopService
(
updateServiceIntent
);
callbackContext
.
success
();
}
else
if
(
ACTION_CONFIGURE
.
equalsIgnoreCase
(
action
))
{
result
=
true
;
try
{
// [authToken, url, stationaryRadius, distanceFilter, locationTimeout, desiredAccuracy, debug]);
...
...
@@ -63,10 +69,13 @@ public class BackgroundGpsPlugin extends CordovaPlugin {
}
catch
(
JSONException
e
)
{
callbackContext
.
error
(
"authToken/url required as parameters: "
+
e
.
getMessage
());
return
false
;
}
}
else
if
(
ACTION_SET_CONFIG
.
equalsIgnoreCase
(
action
))
{
result
=
true
;
// TODO reconfigure Service
callbackContext
.
success
();
}
return
true
;
return
result
;
}
}
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