[General Topics] GalaxyA325G:
How can I set a HARDWARE button to MUTE the phone (perhaps via a one-tap Android System Sounds and Vibration settings shortcut)?

Note that the question is generic about setting HARDWARE buttons to custom one-tap shortcuts, where the random example, in this case, is the mute switch (knowing full well that just holding the "volume down" button will mute the phone - but that's not the point).

View attachment 6001911

Being the industrious type, I decided to see if I could make my own hardware button to a custom shortcut which I've never done before, but it shouldn't be hard (should it?) since Android can do anything you want it to do, right?

Almost arbitrarily, I decided to reproduce the iPhone hardware mute switch (where this is just an example - the important thing is to set a hardware switch to a one-tap custom homescreen shortcut).

First, I needed to find the name of the package & activity for the default Android mute

Start any good activity inspector (which reports public activities).

Settings > Sounds and vibration > Vibrate (or Mute)

Go back to the activity inspector to find the public activity

Drat. It's not a visibly exported public activity after all. Sigh.

Since it's not a visibly exported public activity, let's dig deeper, shall we?

Install any good Activity Manager, for example this FOSS "Activity Manager" on GitHub & F-Droid.

Activity Manager FOSS by sdex (Yurii Mysochenko)

<https://github.com/sdex/ActivityManager>

<https://f-droid.org/packages/com.activitymanager/>

Start that Foss "Activity Manager" app

Make sure "Show system apps" is turned on

Then search for the activities in the "Settings" entry

(or scroll down to "Settings - com.android.settings")

Once you have "Settings com.android.settings" open, search for "sound", which will bring up three entries

System sound (Settings$SecSoundSystemSoundSettingsActivity)

Sounds and vibration (Settings$SoundSettingsActivity)

Sounds and vibration (SoundSettings)

Tap on each one to test which one you are seeking

The first takes you to the sound volume slider,

And the other two take you to where you want to go.

Press the three dots to the right of the middle entry

A dialog will pop up asking

Create shortcut

Launch activity with parameters

Launch activity with ROOT

Choose "Launch activity with parameters"

This finally reveals the two unique pieces of data you need

Package name = com.android.settings

Class name = com.android.settings.Settings$SoundSettingsActivity

Once you have those two things, it's easy to manually create a one-tap homescreen shortcut to that package/activity (aka class).

[Tutorial] Illustrated (mostly privacy based) one-tap shortcuts so that you can access (in a single tap!) any buried Android setting or app activity

But this app will create that shortcut for you, so why bother?

Go back and this time select "Create shortcut" instead.

This will pop up a "Sounds and vibration" shortcut-editor

If desired, change the icon to whatever you like

If desired, change the label of that shortcut to "Mute"

Then press "Create"

This brings up an "Add to Home screen" dialog box

Edit the icon & label as desired

Longpress on the icon to place it on your homescreen where desired.

Voila!

You now have a one-tap shortcut on your homescreen to the private (unexported) Android system "Sounds & vibration" settings activity.

Now how can we set that one-tap "Mute" shortcut to a hardware button?

Note that you can download all sorts of icon packs but I find it easiest to create my own custom 48x48 pixel PNG icons simply by searching images.google.com for the appropriate keywords and modifying a screenshot of a suitable result using Irfanview and Paint.NET freeware on Windows.

View attachment 6001913