Android Question Vibrate when ringing

bgsoft

Well-Known Member
Licensed User
Longtime User
First of all Congratulations on the new look of the forum.

It can be put Toggle Library vibrator mode, but then it will not sound

B4X:
Dim m As Toggle
m.TurnRingerMode (m.RINGER_MODE_VIBRATE)


I tried this but does not work :rolleyes:

B4X:
Dim m As Toggle
m.TurnRingerMode (bit.Or (m.RINGER_MODE_VIBRATE, m.RINGER_MODE_NORMAL))


You can enable this option by code? (attached image)


thanks

Jesus
 

Attachments

  • Screenshot_2013-07-17-10-08-49.png
    Screenshot_2013-07-17-10-08-49.png
    160.3 KB · Views: 266

Erel

B4X founder
Staff member
Licensed User
Longtime User
Starting from Android 4 you can use this code:
B4X:
Sub SetVibrateWhenRinging(Enabled As Boolean)
   Dim val As Int
   If Enabled Then val = 1 Else val = 0
   Dim r As Reflector
   r.Target = r.GetContext
   r.Target = r.RunMethod("getContentResolver")
   r.RunStaticMethod("android.provider.Settings$System", "putInt", _
     Array As Object(r.Target, "vibrate_when_ringing", val), _
     Array As String("android.content.ContentResolver", "java.lang.String", "java.lang.int"))
End Sub
 
Upvote 0

bgsoft

Well-Known Member
Licensed User
Longtime User
Thank you so much Erel
Where I can find the methods, the RunMethod calls?.

note: I like the new look of the forum, to see all of the above in the response is very good :). Congratulations again.
 
Upvote 0
Top