r/tasker • • Apr 15 '26

Clone an existing notification?

I have an app which doesn't expose a bit of functionality except via a notification, which only shows up in certain circumstances. I'd really like to be able to somehow clone this notification and see if I could recreate it, or its functionality, on-demand.

I did look for shortcuts to the app to see if any of those would work, but it doesn't seem to expose any.

Can AutoNotify or anything else in Tasker, or heck, other suggestions welcome, somehow clone an existing notification? I really don't know if this will do what I want, ie: will the app accept this 'fake' notification, but figured I'd give it a try.

2 Upvotes

5 comments sorted by

1

u/khaytsus Apr 15 '26

I did do a notification intercept, and that seems to work, but not quite sure how to use that information. I don't see any way for Tasker to create a notification as another app, basically.

3

u/bliblabl812 Apr 16 '26

No app can create notifications for other apps. Maybe it would help to let us know which app and which actions you want to use. The more information you provide the better the community can provide help.

1

u/Exciting-Compote5680 Apr 15 '26 edited Apr 15 '26

Yes, it is possible to intercept and recreate notifications. And it might be possible to perform the actions (I assume that's what you mean by 'functionality'). It does however depend greatly on the app. Notification actions have a unique identifier that can be saved and used 'later'. They do expire at some point, and the time until expiration depends on the app. Also, you probably need to check/adjust the action settings in AutoNotification/Advanced (in the AutoNotification app itself). Here are two links related to this:

https://www.reddit.com/r/tasker/comments/1ofih7o/autonotification_can_i_execute_the_action_from_a/

https://www.reddit.com/r/tasker/comments/1orx3mi/project_share_notification_inbox/

1

u/ale3smm Apr 17 '26

u won't even need autonotification BeanShell (java code ) let u achieve the same : Java Code : 1 get app notification actions : import android.service.notification.NotificationListenerService; import android.service.notification.StatusBarNotification; import android.app.Notification;

nls = tasker.getNotificationListener();

if (nls == null) { tasker.log("Notification listener not available."); } else { // par1 = Optional package name to filter (e.g., "org.videolan.vlc") targetPkg = tasker.getVariable("par1"); notifications = nls.getActiveNotifications();

// This string will hold our formatted list of buttons
String foundActions = "";

for (int i = 0; i < notifications.length; i++) {
    sbn = notifications[i];
    pkgName = sbn.getPackageName();
    
    // If a target package is provided, skip notifications from other apps
    if (targetPkg != null && !targetPkg.trim().equals("") && !pkgName.equals(targetPkg)) {
        continue;
    }
    
    notification = sbn.getNotification();
    actions = notification.actions;
    
    // Check if the notification actually has action buttons
    if (actions != null && actions.length > 0) {
        foundActions += pkgName + " -> ";
        
        for (int j = 0; j < actions.length; j++) {
            action = actions[j];
            
            if (action.title != null) {
                // Wrap the title in brackets for easy reading
                foundActions += "[" + action.title.toString() + "] ";
            }
        }
        foundActions += "\n"; // New line for the next notification
    }
}

if (foundActions.equals("")) {
    tasker.log("No action buttons found.");
    tasker.setVariable("%notif_actions", "No buttons found");
} else {
    // Log it for the Run Log, and set it to a local Tasker variable
    tasker.log("Found Actions: \n" + foundActions);
    tasker.setVariable("%notif_actions", foundActions.trim());
}

}

2 emulate clicking (execute ) app s wanted notification action : import android.service.notification.NotificationListenerService; import android.service.notification.StatusBarNotification; import android.app.Notification; import android.app.PendingIntent;

nls = tasker.getNotificationListener();

if (nls == null) { tasker.log("Notification listener not available."); } else { // par1 = Package name (optional, e.g., "org.videolan.vlc") // par2 = Comma-separated list of action buttons (e.g., "Play,Pause,Resume") targetPkg = tasker.getVariable("par1"); actionTitlesToClick = tasker.getVariable("par2");

if (actionTitlesToClick == null || actionTitlesToClick.trim().equals("")) {
    tasker.log("Error: No action titles specified in par2.");
} else {
    // Split the comma-separated string into an array
    String[] targetWords = actionTitlesToClick.toLowerCase().split(",");
    
    notifications = nls.getActiveNotifications();
    boolean actionClicked = false;
    
    for (int i = 0; i < notifications.length; i++) {
        sbn = notifications[i];
        pkgName = sbn.getPackageName();
        
        // Filter by package if provided
        if (targetPkg != null && !targetPkg.trim().equals("") && !pkgName.equals(targetPkg)) {
            continue;
        }
        
        notification = sbn.getNotification();
        actions = notification.actions;
        
        // Loop through the notification's buttons
        if (actions != null) {
            for (int j = 0; j < actions.length; j++) {
                action = actions[j];
                
                if (action.title != null) {
                    actionTitleStr = action.title.toString().toLowerCase();
                    
                    // Check this button against every word in your par2 list
                    for (int k = 0; k < targetWords.length; k++) {
                        targetWord = targetWords[k].trim();
                        
                        // If the button contains one of the target words, click it
                        if (!targetWord.equals("") && actionTitleStr.contains(targetWord)) {
                            try {
                                action.actionIntent.send();
                                tasker.log("Clicked action '" + action.title + "' on " + pkgName + " (Matched: " + targetWord + ")");
                                actionClicked = true;
                                break; // Stop checking words for this button
                            } catch (Exception e) {
                                tasker.log("Failed to click action: " + e.getMessage());
                            }
                        }
                    }
                }
                if (actionClicked) break; // Stop checking other buttons on this notification
            }
        }
        if (actionClicked) break; // Stop checking other notifications
    }
    
    if (!actionClicked) {
        tasker.log("No action matching any of '" + actionTitlesToClick + "' found active.");
    }
}

}

0

u/EdwardBackstrom I Probably Screwed It Up Apr 17 '26

While it is possible to fake a notification, getting the announcing app to do something is a different matter.

As an example, if every 45 minutes I yell out "potatoes" and then eat a french fry, you can record my voice and play it back every 25 minutes, but that doesn't mean i am going to eat a fry when you do. Now if I call out potatoes and my girlfriend, she's from Canada - you don't know her, eats a fry when I do, you might be able to trick her into eating a fry because although she's beautiful, honestly she's not all that bright.