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
1b045a14
Commit
1b045a14
authored
Feb 25, 2014
by
Chris Scott
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Implementing android stationary-region-monitoring
parent
aa765df9
Changes
2
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
542 additions
and
274 deletions
+542
-274
BackgroundGpsPlugin.java
src/android/BackgroundGpsPlugin.java
+48
-48
LocationUpdateService.java
src/android/LocationUpdateService.java
+494
-226
No files found.
src/android/BackgroundGpsPlugin.java
View file @
1b045a14
...
@@ -12,61 +12,61 @@ import android.location.LocationManager;
...
@@ -12,61 +12,61 @@ import android.location.LocationManager;
import
android.util.Log
;
import
android.util.Log
;
public
class
BackgroundGpsPlugin
extends
CordovaPlugin
{
public
class
BackgroundGpsPlugin
extends
CordovaPlugin
{
private
static
final
String
TAG
=
"BackgroundGpsPlugin"
;
private
static
final
String
TAG
=
"BackgroundGpsPlugin"
;
public
static
final
String
ACTION_START
=
"start"
;
public
static
final
String
ACTION_START
=
"start"
;
public
static
final
String
ACTION_STOP
=
"stop"
;
public
static
final
String
ACTION_STOP
=
"stop"
;
public
static
final
String
ACTION_CONFIGURE
=
"configure"
;
public
static
final
String
ACTION_CONFIGURE
=
"configure"
;
private
Intent
updateServiceIntent
;
private
Intent
updateServiceIntent
;
private
String
authToken
;
private
String
authToken
;
private
String
url
;
private
String
url
;
private
String
stationaryRadius
=
"30"
;
private
String
stationaryRadius
=
"30"
;
private
String
desiredAccuracy
=
"100"
;
private
String
desiredAccuracy
=
"100"
;
private
String
distanceFilter
=
"30"
;
private
String
distanceFilter
=
"30"
;
private
String
locationTimeout
=
"60"
;
private
String
locationTimeout
=
"60"
;
private
String
isDebugging
=
"false"
;
private
String
isDebugging
=
"false"
;
public
boolean
execute
(
String
action
,
JSONArray
data
,
CallbackContext
callbackContext
)
{
public
boolean
execute
(
String
action
,
JSONArray
data
,
CallbackContext
callbackContext
)
{
Activity
activity
=
this
.
cordova
.
getActivity
();
Activity
activity
=
this
.
cordova
.
getActivity
();
updateServiceIntent
=
new
Intent
(
activity
,
LocationUpdateService
.
class
);
updateServiceIntent
=
new
Intent
(
activity
,
LocationUpdateService
.
class
);
if
(
ACTION_START
.
equalsIgnoreCase
(
action
))
{
if
(
ACTION_START
.
equalsIgnoreCase
(
action
))
{
if
(
authToken
==
null
||
url
==
null
)
{
if
(
authToken
==
null
||
url
==
null
)
{
callbackContext
.
error
(
"Call configure before calling start"
);
callbackContext
.
error
(
"Call configure before calling start"
);
return
false
;
return
false
;
}
}
updateServiceIntent
.
putExtra
(
"authToken"
,
authToken
);
updateServiceIntent
.
putExtra
(
"authToken"
,
authToken
);
updateServiceIntent
.
putExtra
(
"url"
,
url
);
updateServiceIntent
.
putExtra
(
"url"
,
url
);
updateServiceIntent
.
putExtra
(
"stationaryRadius"
,
stationaryRadius
);
updateServiceIntent
.
putExtra
(
"stationaryRadius"
,
stationaryRadius
);
updateServiceIntent
.
putExtra
(
"desiredAccuracy"
,
desiredAccuracy
);
updateServiceIntent
.
putExtra
(
"desiredAccuracy"
,
desiredAccuracy
);
updateServiceIntent
.
putExtra
(
"distanceFilter"
,
distanceFilter
);
updateServiceIntent
.
putExtra
(
"distanceFilter"
,
distanceFilter
);
updateServiceIntent
.
putExtra
(
"locationTimeout"
,
locationTimeout
);
updateServiceIntent
.
putExtra
(
"locationTimeout"
,
locationTimeout
);
updateServiceIntent
.
putExtra
(
"desiredAccuracy"
,
desiredAccuracy
);
updateServiceIntent
.
putExtra
(
"desiredAccuracy"
,
desiredAccuracy
);
updateServiceIntent
.
putExtra
(
"isDebugging"
,
isDebugging
);
updateServiceIntent
.
putExtra
(
"isDebugging"
,
isDebugging
);
activity
.
startService
(
updateServiceIntent
);
activity
.
startService
(
updateServiceIntent
);
}
else
if
(
ACTION_STOP
.
equalsIgnoreCase
(
action
))
{
}
else
if
(
ACTION_STOP
.
equalsIgnoreCase
(
action
))
{
activity
.
stopService
(
updateServiceIntent
);
activity
.
stopService
(
updateServiceIntent
);
}
else
if
(
ACTION_CONFIGURE
.
equalsIgnoreCase
(
action
))
{
}
else
if
(
ACTION_CONFIGURE
.
equalsIgnoreCase
(
action
))
{
try
{
try
{
// [authToken, url, stationaryRadius, distanceFilter, locationTimeout, desiredAccuracy, debug]);
// [authToken, url, stationaryRadius, distanceFilter, locationTimeout, desiredAccuracy, debug]);
this
.
authToken
=
data
.
getString
(
0
);
this
.
authToken
=
data
.
getString
(
0
);
this
.
url
=
data
.
getString
(
1
);
this
.
url
=
data
.
getString
(
1
);
this
.
stationaryRadius
=
data
.
getString
(
2
);
this
.
stationaryRadius
=
data
.
getString
(
2
);
this
.
distanceFilter
=
data
.
getString
(
3
);
this
.
distanceFilter
=
data
.
getString
(
3
);
this
.
locationTimeout
=
data
.
getString
(
4
);
this
.
locationTimeout
=
data
.
getString
(
4
);
this
.
desiredAccuracy
=
data
.
getString
(
5
);
this
.
desiredAccuracy
=
data
.
getString
(
5
);
this
.
isDebugging
=
data
.
getString
(
6
);
this
.
isDebugging
=
data
.
getString
(
6
);
}
catch
(
JSONException
e
)
{
}
catch
(
JSONException
e
)
{
callbackContext
.
error
(
"authToken/url required as parameters: "
+
e
.
getMessage
());
callbackContext
.
error
(
"authToken/url required as parameters: "
+
e
.
getMessage
());
return
false
;
return
false
;
}
}
}
}
return
true
;
return
true
;
}
}
}
}
src/android/LocationUpdateService.java
View file @
1b045a14
This diff is collapsed.
Click to expand it.
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