VolumeEvents: Listen to volume change events


Description: With this extension you can listen to volume change events and get volume values of different stream types
Latest Version: 1
Released: 2021-03-03T18:30:00Z
Last Updated: 2021-03-03T18:30:00Z




  • Volume Changed
    Event triggered when volume changes
    previousVolume ~ int
    currentVolume ~ int
  • Get Max Volume
    Returns max volume value of given stream type
    Accepts int
    Returns : int
  • Get Min Volume
    Returns min volume value of given stream type
    Accepts int
    Returns : int
  • Get Volume
    Returns current volume value of given stream type
    Accepts int
    Returns : int
  • Start Listening
    Starts listening to volume changes
  • Stop Listening
    Stops listening to volume changes
  • Stream Type
    Sets audio stream type i.e. which stream volume changes should listener listen to
    Accepts int
    Default Value : 3

Stream Values
RING -> 2
MUSIC -> 3
DTMF -> 8
ALARM -> 4


Download Link: com.sunny.VolumeEvents.aix (8.4 KB)

Inspired from here: Extension request: detect volume buttons events - Request - Kodular Community

Hope it helps! :slightly_smiling_face:


Wow, you are incredible @vknow360 :star_struck: :+1:
Good Job :heart_eyes: :+1:

great work!

Great work!

You are amazing, great extension :exploding_head:

1 Like

Hi Sunny

A Challenge: Can you add the ability to disable and enable the physical volume buttons?

... and on the subject of button re-mapping, enabling/disabling of the power button too?

1 Like

Just for volume buttons, when it change set back the old value :thinking:

It is not possible as far as I know.
Some changes are needed in Form.java file to implement those methods.

Maybe try to create extended form if possible with you're extension?

There are Apps that can do it........ bear in mind that it is temporary, when the App is Active.

I meant to say it is not possible with extension.
Obviously it is possible with code in android where you extend Activity but in extension you extend AndroidNonvisibleComponent and Form implements only few methods of Activity.

That is not possible.

1 Like

I see - that also to a certain extent explains why there are few essential extensions amongst a sea of trivial ones. :thinking:

Our work around then could be to create an App (Android Studio Kotlin) specifically for the task and run that App from the main App (App Inventor).

Yes that is the main reason.
It can be solved if some basic changes are made in Form.java file but merging of those changes in ai2 may take some time.

@vknow360 awesome extension... but Can we have blocks like:

When_Headphone_VolumeUp.Clicked -> do :

1 Like

Sure, you can sponser the new features.


How come that??..

Hi vknow360,
thank your for extension.
In my AI2 project, I use the "call VolumeEvents1.getVolume" of stream3, but I keep receiving the error "Attempt to invoke virtual method 'int com.sunny.VolumeEvents.VolumeObserver.getValue(int)' on a null object reference".
Any idea?
I understood "3" is for the Music stream, but it makes no difference whether I play music on the device or not. In both cases, I receive this error.
KR, Oli

I think it will not work in companion and will work in the created app
because the screen recorder extension has the same issue in the companion

yes, I did complie the APK and install. I never work with Companion.

Please pm me the apk link.
Or, if possible, post here the logcat.