Android Question How to activate the touch tones?

Reinald Assheuer

Member
Licensed User
Longtime User
Dear all, I don't konw the correct settings name. In German: Töne bei Berührung

Normally I have deactivated the klicks while touching the phone. But for this special app I'm writing I want to activate them by program start and deactivate them while leaving the app.

I'm not sure if you undertsand me. I add a screenshot from my phone with the feature I mean.

Thanks.
Reinald
 

Attachments

  • Screenshot_20170707-170009.png
    Screenshot_20170707-170009.png
    64.3 KB · Views: 153

Erel

B4X founder
Staff member
Licensed User
Longtime User
You can use this code to change the sound effects setting:
B4X:
Sub SetSoundEffects(Enabled As Boolean)
   Dim context As JavaObject
   context.InitializeContext
   Dim settings As JavaObject
   settings.InitializeStatic("android.provider.Settings.System")
   Dim val As Int
   If Enabled Then val = 1 Else val = 0
   settings.RunMethod("putInt", Array As Object(context.RunMethod("getContentResolver", Null), _
     settings.GetField("SOUND_EFFECTS_ENABLED"), val))
End Sub

Manifest:
B4X:
AddPermission(android.permission.WRITE_SETTINGS)

This will affect the user settings so you need to set it back before your app ends.
 
Upvote 0
Top