Headphones Notification on Your Watch

Create a notification that allows you to launch and play your favorite headphone apps when inserted

  1. joaomgcd
    (i) We're going to create a notification on your wearable device that has these features:
    • appears on your watch when headphones are connected
    • Allows you to tap the small notification card to play the last played media app
    • Gives you an additional screen where all your favorite media apps' icons show up and tapping each one will make that app start playing
    • disappears when headphones are disconnected

    STEP 1 - CREATE "PLAY LAST" TASK


    (i) We're going to start by creating a task that will play whatever the last app you played was.

    • Create a new Task in Tasker and name it "Play Last"
    • Add an "AutoLaunch Query" action
    • Set App Nickname to %LASTPLAYED
    (i) The %LASTPLAYED variable doesn't exist yet, but we're going to set it before calling this task later. It's going to contain the app name of the last played media app.
    • Add a flash action with %alpackages1 just to make sure the query is performed correctly
    (i) %alpackages1 contains the package name (a unique ID for and Android app) of the app you searched for.


    STEP 2 - PRESS PLAY


    • Add an AutoShare action
    • In the App field select Media
    • In the Action field select "Press Play Key Down"
    (i) If you haven't imported this action yet do so by tapping "Get More Intents!". Find the action in the list, tap it and it'll import into AutoShare. Press back and the action will be there for you to use.
    • Under Advanced go to "Android Package" and insert %alpackages1 by tapping the tag icon
    • Go back to Tasker
    • Clone the AutoShare action
    • Edit it
    • Change the action to "Press Play Key Up"
    • Again, set "Android Package" to %alpackages1
    (i) You've added key down and up actions for the play key and directed them to the app you want to play. This will effectively simulate you pressing the "play" button and releasing it in the app.
    /!\ If for any reason you find that the app doesn't always start playing, you may need to launch the app before pressing play. This is a limitation of some apps and not related to the AutoApps. To do so, add an "AutoLaunch" action at the beginning of this task, use %LASTPLAYED, wait 3 seconds and only then perform the rest of the task.


    STEP 3 - WHEN YOUR HEADSET IS PLUGGED IN...


    • Create a new profile in Tasker
    • Select the Headset plugged condition
    • Create a new Task


    STEP 4 - SET %LASTPLAYED DEFAULT VALUE


    • Add a "Variable Set" action
    • Set %LASTPLAYED to "Pocket Casts" but only if %LASTPLAYED isn't already set
    (i) This will set %LASTPLAYED to "Pocket Casts" by default. You can change this to whatever app you prefer to be your default app. Once you play any app with this notification this will be overridden so don't worry too much about it. It's only meant for the very first use of this project.

    /!\ Not in video: Run this task in Tasker now so that the %LASTPLAYED variable is set to "Pocket Casts" or whatever you set it to. If you don't do that, the rest of the project won't work correctly because %LASTPLAYED won't have a value.


    STEP 5 - GETTING LAST PLAYED APP'S ICON


    • Add an "AutoLaunch Query" action
    • Set App Nickname to %LASTPLAYED
    • Add a "Variable Set" action
    • Set %icon to %alicons1 (which is the first icon that was found in the query)
    (i) We're going to use this icon as the main notification icon on your wearable.


    STEP 6 - GET MUSIC APPS


    /!\ For this step to work you need to first go into the AutoLaunch app, manage your apps and set the "AutoWear music" nickname on any apps you want to appear on this notification

    • Add an "AutoLaunch Query" action
    • Set "App Nickname" to "AutoWear music"
    • Add a flash action with %alicons() and %allabels() just to make these variables easier to use in the next steps. You can disable this step if you want (not delete it)


    STEP 7 - CREATE AUTOWEAR NOTIFICATION


    • Add an "AutoWear Notification" action
    • Give it a name: "music"
    • Set the title to "Music"
    • Set the text to "Play %LASTPLAYED?"
    • Set icon to %icon
    • Set hint icon to a guitar (or anything you like)
    • Set priority to max
    • Set the vibration pattern you want


    STEP 8 - CONFIGURE BUTTON INSIDE NOTIFICATION


    • Set button action to "play=:=%LASTPLAYED"
    • Select the "play" icon as the button icon
    • Check the "Content Icon" option
    (i) By selecting this option you'll make this button appear inside the main notification card itself instead of appearing as a separate button on a different page


    STEP 9 - CREATE CUSTOM BUTTONS SCREEN


    • Tap the "Custom Screens" button
    • Tap "Add Screen"
    • Choose "Buttons Screen" from the list
    • In the "Images" field write "%alicons()"
    • In the "Commands" field write "%allabels()"
    • In the "Command Prefix" field write "play"
    • Set button size to 90
    • Accept the screen and go back to the notification configuration screen
    (i) On a buttons screen image 1 will correspond to command 1, image 2 to command 2, etc. %alicons() contains a list of icons and %allabels() contains a list of app names. Using these will make AutoWear create a button with a correponding command for each app AutoLaunch found. The Command prefix will make each command have "play=:=" prefixed to it so you can react to it in the profile we're creating next.


    STEP 10 - REACTING TO PLAY=:=


    • Go back to Tasker and create a new profile with the "AutoWear Command" condition
    • In the command filter write "play=:="
    • Accept that and create a new task
    (i) This profile will trigger whenever AutoWear sends a command with "play=:=" this will happen when you click the notification itself or any button in the buttons screen that you create above. Anything to the right of =:= will be available in %awcomm in this task. Check here for more info on this command system.


    STEP 11 - SET %LASTPLAYED AND RUN TASK "LAST PLAYED"


    • Add a "variable set" action
    • Set %LASTPLAYED to %awcomm
    • Add a "Perform Task" action
    • Select the "Last Played" task to run


    STEP 12 - CANCEL NOTIFICATION


    • Go back to tasker and add an exit task to the first profile you created
    • Add an "AutoWear App" action
    • Under "Action" select "Delete"
    • Under "AutoWear Element Name" write "music" (which is the name you gave the notification)



    (i) You can now test this. Insert your headphones and a notification should show up on your wearable device. If you touch it, Pocket Casts should start playing (or whatever app you used in Step 4). If you swipe it to the left you'll see the buttons corresponding to each app you named "AutoWear music" in AutoLaunch. If you remove your headphones the notification should disappear from your wear device.

Recent Reviews

  1. zwizard
    zwizard
    5/5,
    Works super great!!! I changed mine to work when connected to my car's bluetooth.
  2. Jonatan
    Jonatan
    5/5,
    Awsome use of AutoWear. Works very well for me after I've modified it a bit for my special needs.