Can't seem to set vibrate ringer mode

rfresh

Well-Known Member
Licensed User
Longtime User
I'm trying to set my ringer to vibrate mode with this line:

B4X:
p.SetRingerMode(p.RINGER_VIBRATE)

However, when I look at my Sound Settings on my Droid3, I see the Silent mode checkbox is checked and Vibrate is set to Never.

So, obviously, my one liner isn't setting vibrate mode. Is there something else I have to set too?

Thanks...
 

rfresh

Well-Known Member
Licensed User
Longtime User
I was searching around for an answer to coding vibrate mode on and off and found this (see attachment) -- do I need to be using "Audio Manager" calls beside the one line of code I am using now (which doesn't work)?

Thanks...
 

Attachments

  • 1.jpg
    1.jpg
    65.5 KB · Views: 330
Upvote 0

rfresh

Well-Known Member
Licensed User
Longtime User
Ok, cool. I see this helpful Android API reference for the Audio Manager:

Android API AudioManager

So I want to use the VIBRATE_SETTING_OFF constant shown in this listing but what method do I call it with in b4a? SetRingerMode()? Are all Audio Manager calls made using this method?

I can't find a good cross reference to this Android API listing and b4a. Your b4a Audio.html here doesn't seem to match.

The constants shown in this Android API listing are not the same constants as used in b4a; VIBRATE_SETTING_OFF is equal to RINGER_VIBRATE (b4a).

So I'm back to my same problem:

B4X:
p.SetRingerMode(p.RINGER_VIBRATE)

...doesn't work...Settings Vibrate stills shows "Never".

Do we have a SetVibrateSetting() method like this one shown in the Android API Audio Manager listing:

public static final int VIBRATE_SETTING_OFF
Since: API Level 1

Vibrate setting that suggests to never vibrate.
See Also

setVibrateSetting(int, int)
getVibrateSetting(int)

Constant Value: 0 (0x00000000)
 
Last edited:
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
The constants in the Phone library are the constants used by AudioManager.setRingerMode.

You can use the Reflection library to call setVibrateSetting:
B4X:
Sub SetVibrateSetting(VibrateType As Int, VibrateSetting As Int)
   Dim r As Reflector
   r.Target = r.GetContext
   r.Target = r.RunMethod2("getSystemService", "audio", "java.lang.String")
   r.RunMethod3("setVibrateSetting", VibrateType, "java.lang.int", VibrateSetting, "java.lang.int")
End Sub
 
Upvote 0
Top