|
|
@@ -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;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -79,6 +88,13 @@ abstract public class AbstractClickReceiver extends Activity {
|
|
|
return getIntent().getExtras().getString(EXTRA_ID, CLICK_ACTION_ID);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * Getter for the received intent.
|
|
|
+ */
|
|
|
+ protected Intent getIntent() {
|
|
|
+ return intent;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* Launch main intent from package.
|
|
|
*/
|
|
|
@@ -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);
|
|
|
}
|