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