B bitmap1374 Member Licensed User May 22, 2021 #1 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
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 B B bitmap1374 Jun 18, 2021 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
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
Erel B4X founder Staff member Licensed User Longtime User May 23, 2021 #2 1. SetEarPhone: https://www.b4x.com/android/forum/t...ker-instead-of-loudspeaker.19842/#post-114472 2. Use the approximate sensor (PhoneSensors from Phone library) to find out when the phone is close to the ear. Upvote 0
1. SetEarPhone: https://www.b4x.com/android/forum/t...ker-instead-of-loudspeaker.19842/#post-114472 2. Use the approximate sensor (PhoneSensors from Phone library) to find out when the phone is close to the ear.
B bitmap1374 Member Licensed User May 31, 2021 #3 Erel said: 1. SetEarPhone: https://www.b4x.com/android/forum/t...ker-instead-of-loudspeaker.19842/#post-114472 2. Use the approximate sensor (PhoneSensors from Phone library) to find out when the phone is close to the ear. Click to expand... this code no work correctly for set earphone Upvote 0
Erel said: 1. SetEarPhone: https://www.b4x.com/android/forum/t...ker-instead-of-loudspeaker.19842/#post-114472 2. Use the approximate sensor (PhoneSensors from Phone library) to find out when the phone is close to the ear. Click to expand... this code no work correctly for set earphone
B bitmap1374 Member Licensed User Jun 18, 2021 #4 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
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