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
37f2cd9f
Commit
37f2cd9f
authored
Feb 26, 2014
by
Chris Scott
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'android'
parents
50ff5a81
0658b684
Changes
7
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
514 additions
and
274 deletions
+514
-274
README.md
README.md
+2
-0
index.js
example/www/js/index.js
+2
-0
plugin.xml
plugin.xml
+1
-1
BackgroundGpsPlugin.java
src/android/BackgroundGpsPlugin.java
+69
-35
LocationUpdateService.java
src/android/LocationUpdateService.java
+439
-237
android-support-v4.jar
src/android/android-support-v4.jar
+0
-0
BackgroundGeoLocation.js
www/BackgroundGeoLocation.js
+1
-1
No files found.
README.md
View file @
37f2cd9f
...
@@ -68,6 +68,8 @@ A full example could be:
...
@@ -68,6 +68,8 @@ A full example could be:
// BackgroundGeoLocation is highly configurable.
// BackgroundGeoLocation is highly configurable.
bgGeo.configure(callbackFn, failureFn, {
bgGeo.configure(callbackFn, failureFn, {
url: 'http://only.for.android.com/update_location.json', // <-- only required for Android; ios allows javascript callbacks for your http
authToken: 'user_secret_auth_token', // <-- only required for Android; ios allows javascript callbacks for your http
desiredAccuracy: 10,
desiredAccuracy: 10,
stationaryRadius: 20,
stationaryRadius: 20,
distanceFilter: 30,
distanceFilter: 30,
...
...
example/www/js/index.js
View file @
37f2cd9f
...
@@ -90,6 +90,8 @@ var app = {
...
@@ -90,6 +90,8 @@ var app = {
// BackgroundGeoLocation is highly configurable.
// BackgroundGeoLocation is highly configurable.
bgGeo
.
configure
(
callbackFn
,
failureFn
,
{
bgGeo
.
configure
(
callbackFn
,
failureFn
,
{
url
:
'
http://only.for.android.com/update_location.json
'
,
// <-- only required for Android; ios allows javascript callbacks for your http
authToken
:
'
user_secret_auth_token
'
,
// <-- only required for Android; ios allows javascript callbacks for your http
desiredAccuracy
:
10
,
desiredAccuracy
:
10
,
stationaryRadius
:
20
,
stationaryRadius
:
20
,
distanceFilter
:
30
,
distanceFilter
:
30
,
...
...
plugin.xml
View file @
37f2cd9f
...
@@ -30,13 +30,13 @@
...
@@ -30,13 +30,13 @@
<source-file
src=
"src/android/data/sqlite/SQLiteLocationDAO.java"
target-dir=
"src/com/tenforwardconsulting/cordova/bgloc/data/sqlite"
/>
<source-file
src=
"src/android/data/sqlite/SQLiteLocationDAO.java"
target-dir=
"src/com/tenforwardconsulting/cordova/bgloc/data/sqlite"
/>
<source-file
src=
"src/android/notification.png"
target-dir=
"res/drawable"
/>
<source-file
src=
"src/android/notification.png"
target-dir=
"res/drawable"
/>
<source-file
src=
"src/android/android-support-v4.jar"
target-dir=
"libs"
/>
<config-file
target=
"AndroidManifest.xml"
parent=
"/manifest/application"
>
<config-file
target=
"AndroidManifest.xml"
parent=
"/manifest/application"
>
<service
android:name=
"com.tenforwardconsulting.cordova.bgloc.LocationUpdateService"
android:enabled=
"true"
android:process=
":remote"
/>
<service
android:name=
"com.tenforwardconsulting.cordova.bgloc.LocationUpdateService"
android:enabled=
"true"
android:process=
":remote"
/>
</config-file>
</config-file>
<config-file
target=
"AndroidManifest.xml"
parent=
"/manifest"
>
<config-file
target=
"AndroidManifest.xml"
parent=
"/manifest"
>
<uses-permission
android:name=
"android.permission.ACCESS_NETWORK_STATE"
/>
<uses-permission
android:name=
"android.permission.ACCESS_COARSE_LOCATION"
/>
<uses-permission
android:name=
"android.permission.ACCESS_COARSE_LOCATION"
/>
<uses-permission
android:name=
"android.permission.ACCESS_FINE_LOCATION"
/>
<uses-permission
android:name=
"android.permission.ACCESS_FINE_LOCATION"
/>
<uses-permission
android:name=
"android.permission.ACCESS_LOCATION_EXTRA_COMMANDS"
/>
<uses-permission
android:name=
"android.permission.ACCESS_LOCATION_EXTRA_COMMANDS"
/>
...
...
src/android/BackgroundGpsPlugin.java
View file @
37f2cd9f
...
@@ -6,42 +6,76 @@ import org.json.JSONArray;
...
@@ -6,42 +6,76 @@ import org.json.JSONArray;
import
org.json.JSONException
;
import
org.json.JSONException
;
import
android.app.Activity
;
import
android.app.Activity
;
import
android.content.Context
;
import
android.content.Intent
;
import
android.content.Intent
;
import
android.location.LocationManager
;
import
android.util.Log
;
public
class
BackgroundGpsPlugin
extends
CordovaPlugin
{
public
class
BackgroundGpsPlugin
extends
CordovaPlugin
{
public
static
final
String
ACTION_START
=
"start"
;
private
static
final
String
TAG
=
"BackgroundGpsPlugin"
;
public
static
final
String
ACTION_STOP
=
"stop"
;
public
static
final
String
ACTION_CONFIGURE
=
"configure"
;
public
static
final
String
ACTION_START
=
"start"
;
public
static
final
String
ACTION_STOP
=
"stop"
;
private
String
authToken
;
public
static
final
String
ACTION_CONFIGURE
=
"configure"
;
private
String
url
;
public
static
final
String
ACTION_SET_CONFIG
=
"setConfig"
;
@Override
private
Intent
updateServiceIntent
;
public
boolean
execute
(
String
action
,
JSONArray
data
,
CallbackContext
callbackContext
)
{
Activity
activity
=
this
.
cordova
.
getActivity
();
private
String
authToken
;
Intent
updateServiceIntent
=
new
Intent
(
activity
,
LocationUpdateService
.
class
);
private
String
url
;
if
(
ACTION_START
.
equalsIgnoreCase
(
action
))
{
private
String
stationaryRadius
=
"30"
;
if
(
authToken
==
null
||
url
==
null
)
{
private
String
desiredAccuracy
=
"100"
;
callbackContext
.
error
(
"Call configure before calling start"
);
private
String
distanceFilter
=
"30"
;
return
false
;
private
String
locationTimeout
=
"60"
;
}
private
String
isDebugging
=
"false"
;
updateServiceIntent
.
putExtra
(
"authToken"
,
authToken
);
updateServiceIntent
.
putExtra
(
"url"
,
url
);
public
boolean
execute
(
String
action
,
JSONArray
data
,
CallbackContext
callbackContext
)
{
activity
.
startService
(
updateServiceIntent
);
Activity
activity
=
this
.
cordova
.
getActivity
();
Boolean
result
=
false
;
}
else
if
(
ACTION_STOP
.
equalsIgnoreCase
(
action
))
{
updateServiceIntent
=
new
Intent
(
activity
,
LocationUpdateService
.
class
);
activity
.
stopService
(
updateServiceIntent
);
if
(
ACTION_START
.
equalsIgnoreCase
(
action
))
{
}
else
if
(
ACTION_CONFIGURE
.
equalsIgnoreCase
(
action
))
{
result
=
true
;
try
{
if
(
authToken
==
null
||
url
==
null
)
{
this
.
authToken
=
data
.
getString
(
0
);
callbackContext
.
error
(
"Call configure before calling start"
);
this
.
url
=
data
.
getString
(
1
);
}
else
{
}
catch
(
JSONException
e
)
{
callbackContext
.
success
();
callbackContext
.
error
(
"authToken/url required as parameters: "
+
e
.
getMessage
());
updateServiceIntent
.
putExtra
(
"authToken"
,
authToken
);
return
false
;
updateServiceIntent
.
putExtra
(
"url"
,
url
);
}
updateServiceIntent
.
putExtra
(
"stationaryRadius"
,
stationaryRadius
);
}
updateServiceIntent
.
putExtra
(
"desiredAccuracy"
,
desiredAccuracy
);
updateServiceIntent
.
putExtra
(
"distanceFilter"
,
distanceFilter
);
return
true
;
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]);
this
.
authToken
=
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
);
}
catch
(
JSONException
e
)
{
callbackContext
.
error
(
"authToken/url required as parameters: "
+
e
.
getMessage
());
}
}
else
if
(
ACTION_SET_CONFIG
.
equalsIgnoreCase
(
action
))
{
result
=
true
;
// TODO reconfigure Service
callbackContext
.
success
();
}
return
result
;
}
}
}
src/android/LocationUpdateService.java
View file @
37f2cd9f
This diff is collapsed.
Click to expand it.
src/android/android-support-v4.jar
deleted
100644 → 0
View file @
50ff5a81
File deleted
www/BackgroundGeoLocation.js
View file @
37f2cd9f
var
exec
=
require
(
"
cordova/exec
"
);
var
exec
=
require
(
"
cordova/exec
"
);
module
.
exports
=
{
module
.
exports
=
{
configure
:
function
(
success
,
failure
,
config
)
{
configure
:
function
(
success
,
failure
,
config
)
{
var
authToken
=
config
.
auth
_t
oken
||
'
BackgroundGeoLocation_auth_token
'
,
var
authToken
=
config
.
auth
T
oken
||
'
BackgroundGeoLocation_auth_token
'
,
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
...
...
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