Android Question control phone ear speaker

bitmap1374

Member
Licensed User
hi

I want if the phone is placed on the ear. The sound is played through the phone ear speaker

What is the solution?

Thanks for your answers
 
Solution
B4X:
    Dim audiomanager As JavaObject
    audiomanager.InitializeContext
    audiomanager = audiomanager.RunMethod("getSystemService", Array("audio"))
    audiomanager.RunMethod("setMode",Array(3)) ''communication
    audiomanager.RunMethod("setSpeakerphoneOn",Array(False))



B4X:
AddPermission(android.permission.MODIFY_AUDIO_SETTINGS)

This code works correctly

bitmap1374

Member
Licensed User
B4X:
    Dim audiomanager As JavaObject
    audiomanager.InitializeContext
    audiomanager = audiomanager.RunMethod("getSystemService", Array("audio"))
    audiomanager.RunMethod("setMode",Array(3)) ''communication
    audiomanager.RunMethod("setSpeakerphoneOn",Array(False))



B4X:
AddPermission(android.permission.MODIFY_AUDIO_SETTINGS)

This code works correctly
 
Upvote 0
Solution
Top