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
518cb1e2
Commit
518cb1e2
authored
Jul 18, 2014
by
Chris Scott
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'zgiles-flexibleheaders'
parents
00d06e78
92877ef5
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
28 additions
and
12 deletions
+28
-12
BackgroundGpsPlugin.java
src/android/BackgroundGpsPlugin.java
+13
-11
LocationUpdateService.java
src/android/LocationUpdateService.java
+13
-0
BackgroundGeoLocation.js
www/BackgroundGeoLocation.js
+2
-1
No files found.
src/android/BackgroundGpsPlugin.java
View file @
518cb1e2
...
...
@@ -25,6 +25,7 @@ public class BackgroundGpsPlugin extends CordovaPlugin {
private
String
url
;
private
String
params
;
private
String
headers
;
private
String
stationaryRadius
=
"30"
;
private
String
desiredAccuracy
=
"100"
;
private
String
distanceFilter
=
"30"
;
...
...
@@ -40,12 +41,13 @@ public class BackgroundGpsPlugin extends CordovaPlugin {
if
(
ACTION_START
.
equalsIgnoreCase
(
action
)
&&
!
isEnabled
)
{
result
=
true
;
if
(
params
==
null
||
url
==
null
)
{
if
(
params
==
null
||
headers
==
null
||
url
==
null
)
{
callbackContext
.
error
(
"Call configure before calling start"
);
}
else
{
callbackContext
.
success
();
updateServiceIntent
.
putExtra
(
"url"
,
url
);
updateServiceIntent
.
putExtra
(
"params"
,
params
);
updateServiceIntent
.
putExtra
(
"headers"
,
headers
);
updateServiceIntent
.
putExtra
(
"stationaryRadius"
,
stationaryRadius
);
updateServiceIntent
.
putExtra
(
"desiredAccuracy"
,
desiredAccuracy
);
updateServiceIntent
.
putExtra
(
"distanceFilter"
,
distanceFilter
);
...
...
@@ -66,17 +68,17 @@ public class BackgroundGpsPlugin extends CordovaPlugin {
}
else
if
(
ACTION_CONFIGURE
.
equalsIgnoreCase
(
action
))
{
result
=
true
;
try
{
// [params, url, stationaryRadius, distanceFilter, locationTimeout, desiredAccuracy, debug]);
// [params,
headers
url, stationaryRadius, distanceFilter, locationTimeout, desiredAccuracy, debug]);
this
.
params
=
data
.
getString
(
0
);
this
.
url
=
data
.
getString
(
1
);
this
.
stationaryRadius
=
data
.
getString
(
2
);
this
.
distanceFilter
=
data
.
getString
(
3
);
this
.
locationTimeout
=
data
.
getString
(
4
);
this
.
desiredAccuracy
=
data
.
getString
(
5
);
this
.
isDebugging
=
data
.
getString
(
6
);
this
.
notificationTitle
=
data
.
getString
(
7
);
this
.
notificationT
ext
=
data
.
getString
(
8
);
this
.
headers
=
data
.
getString
(
1
);
this
.
url
=
data
.
getString
(
2
);
this
.
stationaryRadius
=
data
.
getString
(
3
);
this
.
distanceFilter
=
data
.
getString
(
4
);
this
.
locationTimeout
=
data
.
getString
(
5
);
this
.
desiredAccuracy
=
data
.
getString
(
6
);
this
.
isDebugging
=
data
.
getString
(
7
);
this
.
notificationT
itle
=
data
.
getString
(
8
);
this
.
notificationText
=
data
.
getString
(
9
);
}
catch
(
JSONException
e
)
{
callbackContext
.
error
(
"authToken/url required as parameters: "
+
e
.
getMessage
());
}
...
...
src/android/LocationUpdateService.java
View file @
518cb1e2
package
com
.
tenforwardconsulting
.
cordova
.
bgloc
;
import
java.util.List
;
import
java.util.Iterator
;
import
org.apache.http.HttpResponse
;
import
org.apache.http.client.methods.HttpPost
;
...
...
@@ -70,6 +71,7 @@ public class LocationUpdateService extends Service implements LocationListener {
private
long
lastUpdateTime
=
0
l
;
private
JSONObject
params
;
private
JSONObject
headers
;
private
String
url
=
"http://192.168.2.15:3000/users/current_location.json"
;
private
float
stationaryRadius
;
...
...
@@ -163,6 +165,7 @@ public class LocationUpdateService extends Service implements LocationListener {
if
(
intent
!=
null
)
{
try
{
params
=
new
JSONObject
(
intent
.
getStringExtra
(
"params"
));
headers
=
new
JSONObject
(
intent
.
getStringExtra
(
"headers"
));
}
catch
(
JSONException
e
)
{
// TODO Auto-generated catch block
e
.
printStackTrace
();
...
...
@@ -198,6 +201,7 @@ public class LocationUpdateService extends Service implements LocationListener {
}
Log
.
i
(
TAG
,
"- url: "
+
url
);
Log
.
i
(
TAG
,
"- params: "
+
params
.
toString
());
Log
.
i
(
TAG
,
"- headers: "
+
headers
.
toString
());
Log
.
i
(
TAG
,
"- stationaryRadius: "
+
stationaryRadius
);
Log
.
i
(
TAG
,
"- distanceFilter: "
+
distanceFilter
);
Log
.
i
(
TAG
,
"- desiredAccuracy: "
+
desiredAccuracy
);
...
...
@@ -669,6 +673,15 @@ public class LocationUpdateService extends Service implements LocationListener {
request
.
setEntity
(
se
);
request
.
setHeader
(
"Accept"
,
"application/json"
);
request
.
setHeader
(
"Content-type"
,
"application/json"
);
Iterator
<
String
>
headkeys
=
headers
.
keys
();
while
(
headkeys
.
hasNext
()
){
String
headkey
=
headkeys
.
next
();
if
(
headkey
!=
null
)
{
Log
.
d
(
TAG
,
"Adding Header: "
+
headkey
+
" : "
+
(
String
)
headers
.
getString
(
headkey
));
request
.
setHeader
(
headkey
,
(
String
)
headers
.
getString
(
headkey
));
}
}
Log
.
d
(
TAG
,
"Posting to "
+
request
.
getURI
().
toString
());
HttpResponse
response
=
httpClient
.
execute
(
request
);
Log
.
i
(
TAG
,
"Response received: "
+
response
.
getStatusLine
());
...
...
www/BackgroundGeoLocation.js
View file @
518cb1e2
...
...
@@ -2,6 +2,7 @@ var exec = require("cordova/exec");
module
.
exports
=
{
configure
:
function
(
success
,
failure
,
config
)
{
var
params
=
JSON
.
stringify
(
config
.
params
||
{}),
headers
=
JSON
.
stringify
(
config
.
headers
||
{}),
url
=
config
.
url
||
'
BackgroundGeoLocation_url
'
,
stationaryRadius
=
(
config
.
stationaryRadius
>=
0
)
?
config
.
stationaryRadius
:
50
,
// meters
distanceFilter
=
(
config
.
distanceFilter
>=
0
)
?
config
.
distanceFilter
:
500
,
// meters
...
...
@@ -15,7 +16,7 @@ module.exports = {
failure
||
function
()
{},
'
BackgroundGeoLocation
'
,
'
configure
'
,
[
params
,
url
,
stationaryRadius
,
distanceFilter
,
locationTimeout
,
desiredAccuracy
,
debug
,
notificationTitle
,
notificationText
]);
[
params
,
headers
,
url
,
stationaryRadius
,
distanceFilter
,
locationTimeout
,
desiredAccuracy
,
debug
,
notificationTitle
,
notificationText
]);
},
start
:
function
(
success
,
failure
,
config
)
{
exec
(
success
||
function
()
{},
...
...
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