From 8d3bda0bafa953d685db2e29979cc5fbe2cb78aa Mon Sep 17 00:00:00 2001 From: codeskyblue Date: Wed, 1 May 2024 09:43:39 +0800 Subject: [PATCH] add flag_mutable for PendingIntent --- app/src/main/java/com/github/uiautomator/Service.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/com/github/uiautomator/Service.java b/app/src/main/java/com/github/uiautomator/Service.java index 97403e7..7036c71 100644 --- a/app/src/main/java/com/github/uiautomator/Service.java +++ b/app/src/main/java/com/github/uiautomator/Service.java @@ -78,14 +78,15 @@ public void onCreate() { .setTicker(getString(R.string.monitor_service_ticker)) .setContentTitle(getString(R.string.monitor_service_title)) .setContentText(getString(R.string.monitor_service_text)) - .setContentIntent(PendingIntent.getActivity(this, NOTIFICATION_ID, notificationIntent, PendingIntent.FLAG_UPDATE_CURRENT)) + .setContentIntent(PendingIntent.getActivity(this, NOTIFICATION_ID, notificationIntent, PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_MUTABLE)) .setWhen(System.currentTimeMillis()); Notification notification = builder.build(); startForeground(NOTIFICATION_ID, notification); + // since atx-agent is remove since uiautomator2 3.x, so the following code is useless HttpPostNotifier notifier = new HttpPostNotifier("http://127.0.0.1:7912"); Context context = getApplicationContext(); - addMonitor(new BatteryMonitor(context, notifier)); +// addMonitor(new BatteryMonitor(context, notifier)); addMonitor(new WifiMonitor(this, notifier)); } @@ -117,7 +118,6 @@ public int onStartCommand(Intent intent, int flags, int startId) { } else if (ACTION_STOP.equals(action)) { stopSelf(); } - return START_NOT_STICKY; // not start again, when killed by system }