Android Question ToneGenerator tones

Mostez

Well-Known Member
Licensed User
Longtime User
I want to pass args to this sub (in QR reader example by @Johan Schoeman) to generate different tones as needed i.e.
B4X:
Jo.RunMethod("playTone", Array as int (streamType, volume))

B4X:
#if Java
import android.media.ToneGenerator;
import android.media.AudioManager;

  public void playTone() {
      final ToneGenerator tg = new ToneGenerator(AudioManager.STREAM_NOTIFICATION, 100);
      tg.startTone(ToneGenerator.TONE_PROP_BEEP);
  }  
#End If

How to do that?
ToneGenerator reference: https://developer.android.com/reference/android/media/ToneGenerator
 

Mostez

Well-Known Member
Licensed User
Longtime User
thank you so much Erel, it works well, may I ask how to pass tg tone constant instead of number like
B4X:
tg.RunMethod("startTone", Array(ToneGenerator.TONE_PROP_BEEP, 100))

or should I create my own constants?
 
Upvote 0
Top