VolumeEvents: Listen to volume change events

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 :
Something...

1 Like

Sure, you can sponser the new features.

2 Likes

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.

Hi vknow360,

here i loop over all 8 streams, fetching the volume, while i played music on my smartphone, so I was assuming, stream 3 would write a volume level into my log.
Below the loop, I said, if sztream 3 volume level is GT 10 (meaning, if sound is on anyway), i would like to have spoken output.

This all would just be a work-around: What I wanted to check originally: Whether the user has its smartphone to "silent mopde" (or "vibration only" mode). If so, do not give spoken output. But to check that seems to be quite impossible, I understood.

KR, Oli

Um....

Did you start the listener before executing the block? That's necessary.

1 Like

Gonna try it.

Hello. your plugin is spectacular, but I have a problem, the volume change is received even without any actual changes. I tried to put both value 3 and value 1 on streamType but the result doesn't change. The action triggered by the .volumeChanged trigger is performed randomly. can you help me?

I add that it detects a lot of volume changes when I press the key to open recent apps on Android (the last key on the right)

Can you please elaborate this a little more?
Also post the aia.

P.S. a different logic solved the issue.
com.sunny.VolumeEvents.aix (8.4 KB)
(this is not an update)

It does not work