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
c4a65d5b
Commit
c4a65d5b
authored
Jun 09, 2014
by
shutupwesley
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add ability to customize the notification title and text.
parent
601c310b
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
21 additions
and
7 deletions
+21
-7
BackgroundGpsPlugin.java
src/android/BackgroundGpsPlugin.java
+6
-0
LocationUpdateService.java
src/android/LocationUpdateService.java
+10
-4
BackgroundGeoLocation.js
www/BackgroundGeoLocation.js
+5
-3
No files found.
src/android/BackgroundGpsPlugin.java
View file @
c4a65d5b
...
@@ -30,6 +30,8 @@ public class BackgroundGpsPlugin extends CordovaPlugin {
...
@@ -30,6 +30,8 @@ public class BackgroundGpsPlugin extends CordovaPlugin {
private
String
distanceFilter
=
"30"
;
private
String
distanceFilter
=
"30"
;
private
String
locationTimeout
=
"60"
;
private
String
locationTimeout
=
"60"
;
private
String
isDebugging
=
"false"
;
private
String
isDebugging
=
"false"
;
private
String
notificationTitle
=
"Background tracking"
;
private
String
notificationText
=
"ENABLED"
;
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
();
...
@@ -50,6 +52,8 @@ public class BackgroundGpsPlugin extends CordovaPlugin {
...
@@ -50,6 +52,8 @@ public class BackgroundGpsPlugin extends CordovaPlugin {
updateServiceIntent
.
putExtra
(
"locationTimeout"
,
locationTimeout
);
updateServiceIntent
.
putExtra
(
"locationTimeout"
,
locationTimeout
);
updateServiceIntent
.
putExtra
(
"desiredAccuracy"
,
desiredAccuracy
);
updateServiceIntent
.
putExtra
(
"desiredAccuracy"
,
desiredAccuracy
);
updateServiceIntent
.
putExtra
(
"isDebugging"
,
isDebugging
);
updateServiceIntent
.
putExtra
(
"isDebugging"
,
isDebugging
);
updateServiceIntent
.
putExtra
(
"notificationTitle"
,
notificationTitle
);
updateServiceIntent
.
putExtra
(
"notificationText"
,
notificationText
);
activity
.
startService
(
updateServiceIntent
);
activity
.
startService
(
updateServiceIntent
);
isEnabled
=
true
;
isEnabled
=
true
;
...
@@ -70,6 +74,8 @@ public class BackgroundGpsPlugin extends CordovaPlugin {
...
@@ -70,6 +74,8 @@ public class BackgroundGpsPlugin extends CordovaPlugin {
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
);
this
.
notificationTitle
=
data
.
getString
(
7
);
this
.
notificationText
=
data
.
getString
(
8
);
}
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 @
c4a65d5b
...
@@ -90,6 +90,8 @@ public class LocationUpdateService extends Service implements LocationListener {
...
@@ -90,6 +90,8 @@ public class LocationUpdateService extends Service implements LocationListener {
private
Integer
scaledDistanceFilter
;
private
Integer
scaledDistanceFilter
;
private
Integer
locationTimeout
=
30
;
private
Integer
locationTimeout
=
30
;
private
Boolean
isDebugging
;
private
Boolean
isDebugging
;
private
String
notificationTitle
=
"Background checking"
;
private
String
notificationText
=
"ENABLED"
;
private
ToneGenerator
toneGenerator
;
private
ToneGenerator
toneGenerator
;
...
@@ -172,15 +174,17 @@ public class LocationUpdateService extends Service implements LocationListener {
...
@@ -172,15 +174,17 @@ public class LocationUpdateService extends Service implements LocationListener {
desiredAccuracy
=
Integer
.
parseInt
(
intent
.
getStringExtra
(
"desiredAccuracy"
));
desiredAccuracy
=
Integer
.
parseInt
(
intent
.
getStringExtra
(
"desiredAccuracy"
));
locationTimeout
=
Integer
.
parseInt
(
intent
.
getStringExtra
(
"locationTimeout"
));
locationTimeout
=
Integer
.
parseInt
(
intent
.
getStringExtra
(
"locationTimeout"
));
isDebugging
=
Boolean
.
parseBoolean
(
intent
.
getStringExtra
(
"isDebugging"
));
isDebugging
=
Boolean
.
parseBoolean
(
intent
.
getStringExtra
(
"isDebugging"
));
notificationTitle
=
intent
.
getStringExtra
(
"notificationTitle"
);
notificationText
=
intent
.
getStringExtra
(
"notificationText"
);
// Build a Notification required for running service in foreground.
// Build a Notification required for running service in foreground.
Intent
main
=
new
Intent
(
this
,
BackgroundGpsPlugin
.
class
);
Intent
main
=
new
Intent
(
this
,
BackgroundGpsPlugin
.
class
);
main
.
setFlags
(
Intent
.
FLAG_ACTIVITY_CLEAR_TOP
|
Intent
.
FLAG_ACTIVITY_SINGLE_TOP
);
main
.
setFlags
(
Intent
.
FLAG_ACTIVITY_CLEAR_TOP
|
Intent
.
FLAG_ACTIVITY_SINGLE_TOP
);
PendingIntent
pendingIntent
=
PendingIntent
.
getActivity
(
this
,
0
,
main
,
PendingIntent
.
FLAG_UPDATE_CURRENT
);
PendingIntent
pendingIntent
=
PendingIntent
.
getActivity
(
this
,
0
,
main
,
PendingIntent
.
FLAG_UPDATE_CURRENT
);
Notification
.
Builder
builder
=
new
Notification
.
Builder
(
this
);
Notification
.
Builder
builder
=
new
Notification
.
Builder
(
this
);
builder
.
setContentTitle
(
"Background tracking"
);
builder
.
setContentTitle
(
notificationTitle
);
builder
.
setContentText
(
"ENABLED"
);
builder
.
setContentText
(
notificationText
);
builder
.
setSmallIcon
(
android
.
R
.
drawable
.
ic_menu_mylocation
);
builder
.
setSmallIcon
(
android
.
R
.
drawable
.
ic_menu_mylocation
);
builder
.
setContentIntent
(
pendingIntent
);
builder
.
setContentIntent
(
pendingIntent
);
Notification
notification
;
Notification
notification
;
...
@@ -199,7 +203,9 @@ public class LocationUpdateService extends Service implements LocationListener {
...
@@ -199,7 +203,9 @@ public class LocationUpdateService extends Service implements LocationListener {
Log
.
i
(
TAG
,
"- desiredAccuracy: "
+
desiredAccuracy
);
Log
.
i
(
TAG
,
"- desiredAccuracy: "
+
desiredAccuracy
);
Log
.
i
(
TAG
,
"- locationTimeout: "
+
locationTimeout
);
Log
.
i
(
TAG
,
"- locationTimeout: "
+
locationTimeout
);
Log
.
i
(
TAG
,
"- isDebugging: "
+
isDebugging
);
Log
.
i
(
TAG
,
"- isDebugging: "
+
isDebugging
);
Log
.
i
(
TAG
,
"- notificationTitle: "
+
notificationTitle
);
Log
.
i
(
TAG
,
"- notificationText: "
+
notificationText
);
this
.
setPace
(
false
);
this
.
setPace
(
false
);
//We want this service to continue running until it is explicitly stopped
//We want this service to continue running until it is explicitly stopped
...
...
www/BackgroundGeoLocation.js
View file @
c4a65d5b
...
@@ -6,14 +6,16 @@ module.exports = {
...
@@ -6,14 +6,16 @@ module.exports = {
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
locationTimeout
=
(
config
.
locationTimeout
>=
0
)
?
config
.
locationTimeout
:
60
,
// seconds
locationTimeout
=
(
config
.
locationTimeout
>=
0
)
?
config
.
locationTimeout
:
60
,
// seconds
desiredAccuracy
=
(
config
.
desiredAccuracy
>=
0
)
?
config
.
desiredAccuracy
:
100
;
// meters
desiredAccuracy
=
(
config
.
desiredAccuracy
>=
0
)
?
config
.
desiredAccuracy
:
100
,
// meters
debug
=
config
.
debug
||
false
;
debug
=
config
.
debug
||
false
,
notificationTitle
=
config
.
notificationTitle
||
"
Background checking
"
,
notificationText
=
config
.
notificationText
||
"
ENABLED
"
;
exec
(
success
||
function
()
{},
exec
(
success
||
function
()
{},
failure
||
function
()
{},
failure
||
function
()
{},
'
BackgroundGeoLocation
'
,
'
BackgroundGeoLocation
'
,
'
configure
'
,
'
configure
'
,
[
params
,
url
,
stationaryRadius
,
distanceFilter
,
locationTimeout
,
desiredAccuracy
,
debug
]);
[
params
,
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