Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
SmartCloudAppNotificationService
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
baijinqiu
SmartCloudAppNotificationService
Commits
f101361b
Commit
f101361b
authored
May 26, 2020
by
System Administrator
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
增加轮询方法
parent
1e5ccf2d
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
5 deletions
+10
-5
src/android/ONService.java
+7
-3
src/android/onservice/NotificationService.java
+3
-2
No files found.
src/android/ONService.java
View file @
f101361b
...
@@ -51,11 +51,13 @@ public class ONService extends CordovaPlugin {
...
@@ -51,11 +51,13 @@ public class ONService extends CordovaPlugin {
this
.
coolMethod
(
message
,
callbackContext
);
this
.
coolMethod
(
message
,
callbackContext
);
return
true
;
return
true
;
}
}
if
(
action
.
endsWith
(
"getMessage"
))
{
if
(
action
.
endsWith
(
"getMessage"
))
{
callbackContext
.
success
(
NotificationService
.
getOfflineAll
());
callbackContext
.
success
(
NotificationService
.
getOfflineAll
());
NotificationService
.
cleanOfflineBean
();
NotificationService
.
cleanOfflineBean
();
return
true
;
return
true
;
}
}
// 开启并绑定服务并5秒间隔调取getHistory()
// 开启并绑定服务并5秒间隔调取getHistory()
if
(
action
.
equals
(
"bindService"
))
{
if
(
action
.
equals
(
"bindService"
))
{
Intent
intent
=
new
Intent
(
cordova
.
getActivity
(),
NotificationService
.
class
);
Intent
intent
=
new
Intent
(
cordova
.
getActivity
(),
NotificationService
.
class
);
...
@@ -72,6 +74,8 @@ public class ONService extends CordovaPlugin {
...
@@ -72,6 +74,8 @@ public class ONService extends CordovaPlugin {
connection
,
connection
,
Service
.
BIND_AUTO_CREATE
Service
.
BIND_AUTO_CREATE
);
);
callbackContext
.
success
(
"服务开启成功"
);
return
true
;
}
}
// 开始间隔调取getHistory()
// 开始间隔调取getHistory()
...
...
src/android/onservice/NotificationService.java
View file @
f101361b
...
@@ -115,7 +115,7 @@ public class NotificationService extends Service {
...
@@ -115,7 +115,7 @@ public class NotificationService extends Service {
public
MyBinder
binder
=
new
MyBinder
();
public
MyBinder
binder
=
new
MyBinder
();
public
static
BeanOffline
offlineAll
=
new
BeanOffline
();
;
// 给前端返回的离线数据
public
static
BeanOffline
offlineAll
=
new
BeanOffline
();
// 给前端返回的离线数据
public
static
String
getOfflineAll
()
{
public
static
String
getOfflineAll
()
{
String
res
=
new
Gson
().
toJson
(
offlineAll
);
String
res
=
new
Gson
().
toJson
(
offlineAll
);
...
@@ -357,8 +357,9 @@ public class NotificationService extends Service {
...
@@ -357,8 +357,9 @@ public class NotificationService extends Service {
public
boolean
onUnbind
(
Intent
intent
)
{
public
boolean
onUnbind
(
Intent
intent
)
{
Log
.
e
(
TAG
,
"onUnbind "
);
Log
.
e
(
TAG
,
"onUnbind "
);
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
N
)
{
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
N
)
{
stopForeground
(
STOP_FOREGROUND_REMOVE
);
//
stopForeground(STOP_FOREGROUND_REMOVE);
}
}
stopSelf
();
return
super
.
onUnbind
(
intent
);
return
super
.
onUnbind
(
intent
);
}
}
...
...
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