mirror of
https://bitbucket.org/TheBosZ/cordova-plugin-run-in-background
synced 2024-11-26 01:04:55 +00:00
Fix to only close the correct app rather than all background-mode apps
If you had two apps using this plugin running, clicking "Close" on a notification for one would close both.
This commit is contained in:
parent
0e9b95013d
commit
9c88bba925
@ -82,7 +82,7 @@ public class BackgroundMode extends CordovaPlugin {
|
||||
public void initialize(CordovaInterface cordova, CordovaWebView webView) {
|
||||
super.initialize(cordova, webView);
|
||||
IntentFilter filter = new IntentFilter();
|
||||
filter.addAction("com.backgroundmode.close");
|
||||
filter.addAction("com.backgroundmode.close" + cordova.getContext().getPackageName());
|
||||
cordova.getActivity().registerReceiver(receiver, filter);
|
||||
|
||||
}
|
||||
|
@ -208,7 +208,7 @@ public class ForegroundService extends Service {
|
||||
|
||||
if (settings.optBoolean("allowClose", false)) {
|
||||
|
||||
final Intent clostAppIntent = new Intent("com.backgroundmode.close");
|
||||
final Intent clostAppIntent = new Intent("com.backgroundmode.close" + pkgName);
|
||||
final PendingIntent closeIntent = PendingIntent.getBroadcast(context, 1337, clostAppIntent, 0);
|
||||
final String closeIconName = settings.optString("closeIcon", "power");
|
||||
NotificationCompat.Action.Builder closeAction = new NotificationCompat.Action.Builder(getIconResId(closeIconName), settings.optString("closeTitle", "Close"), closeIntent);
|
||||
|
Loading…
Reference in New Issue
Block a user