Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
C
cordova-plugin-local-notifications
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
Nabil Sadki
cordova-plugin-local-notifications
Commits
c008cc68
Commit
c008cc68
authored
Feb 16, 2018
by
Sebastián Katzer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Migrate from activity to service to handle the click events
parent
77c8ab29
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
28 additions
and
13 deletions
+28
-13
plugin.xml
plugin.xml
+1
-3
Builder.java
src/android/notification/Builder.java
+3
-3
AbstractClickReceiver.java
src/android/notification/receiver/AbstractClickReceiver.java
+24
-7
No files found.
plugin.xml
View file @
c008cc68
...
...
@@ -115,10 +115,8 @@
android:name=
"de.appplant.cordova.plugin.localnotification.ClearReceiver"
android:exported=
"false"
/>
<
activity
<
service
android:name=
"de.appplant.cordova.plugin.localnotification.ClickReceiver"
android:launchMode=
"singleInstance"
android:theme=
"@android:style/Theme.Translucent"
android:exported=
"false"
/>
<receiver
...
...
src/android/notification/Builder.java
View file @
c008cc68
...
...
@@ -353,7 +353,7 @@ public final class Builder {
int
reqCode
=
random
.
nextInt
();
PendingIntent
contentIntent
=
PendingIntent
.
get
Activity
(
PendingIntent
contentIntent
=
PendingIntent
.
get
Service
(
context
,
reqCode
,
intent
,
FLAG_UPDATE_CURRENT
);
builder
.
setContentIntent
(
contentIntent
);
...
...
@@ -403,8 +403,8 @@ public final class Builder {
int
reqCode
=
random
.
nextInt
();
return
PendingIntent
.
get
Activity
(
context
,
reqCode
,
intent
,
FLAG_
CANCEL
_CURRENT
);
return
PendingIntent
.
get
Service
(
context
,
reqCode
,
intent
,
FLAG_
UPDATE
_CURRENT
);
}
/**
...
...
src/android/notification/receiver/AbstractClickReceiver.java
View file @
c008cc68
...
...
@@ -21,7 +21,7 @@
package
de
.
appplant
.
cordova
.
plugin
.
notification
.
receiver
;
import
android.app.
Activity
;
import
android.app.
IntentService
;
import
android.content.Context
;
import
android.content.Intent
;
import
android.os.Bundle
;
...
...
@@ -38,16 +38,25 @@ import static de.appplant.cordova.plugin.notification.action.Action.EXTRA_ID;
* Abstract content receiver activity for local notifications. Creates the
* local notification and calls the event functions for further proceeding.
*/
abstract
public
class
AbstractClickReceiver
extends
Activity
{
abstract
public
class
AbstractClickReceiver
extends
IntentService
{
// Holds a reference to the intent to handle.
private
Intent
intent
;
public
AbstractClickReceiver
()
{
super
(
"LocalNotificationClickReceiver"
);
}
/**
* Called when local notification was clicked to launch the main intent.
*/
@Override
protected
void
onResume
()
{
super
.
onResume
();
protected
void
onHandleIntent
(
Intent
intent
)
{
this
.
intent
=
intent
;
if
(
intent
==
null
)
return
;
Intent
intent
=
getIntent
();
Bundle
bundle
=
intent
.
getExtras
();
Context
context
=
getApplicationContext
();
...
...
@@ -61,7 +70,7 @@ abstract public class AbstractClickReceiver extends Activity {
return
;
onClick
(
toast
,
bundle
);
finish
()
;
this
.
intent
=
null
;
}
/**
...
...
@@ -80,6 +89,13 @@ abstract public class AbstractClickReceiver extends Activity {
}
/**
* Getter for the received intent.
*/
protected
Intent
getIntent
()
{
return
intent
;
}
/**
* Launch main intent from package.
*/
protected
void
launchApp
()
{
...
...
@@ -94,7 +110,8 @@ abstract public class AbstractClickReceiver extends Activity {
return
;
intent
.
addFlags
(
FLAG_ACTIVITY_REORDER_TO_FRONT
|
FLAG_ACTIVITY_SINGLE_TOP
);
FLAG_ACTIVITY_REORDER_TO_FRONT
|
FLAG_ACTIVITY_SINGLE_TOP
);
context
.
startActivity
(
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