Share your experience!
I've tested my device XZ.
Sony XZ have some problem in dectecting audio source.
My test code is below
audioDeviceInfo.getType() is always return 1
(see the reference. that means "TYPE_BUILTIN_EARPIECE")
for (int i = 0; i <devices.length; i++) {
AudioDeviceInfo device = devices[i];
Log.d("csl", "isHeadsetOn: device type "+device.getType());
}So, Mabe you should check your firmware.
In normal case,
when we plug in a earphone, it should return 4 (TYPE_WIRED_HEADPHONES)
when we plug in a headset(earphone with microphone), it should return 3 (TYPE_WIRED_HEADSET)
when we connect with Bluetooth, it should return 7 or 8 (TYPE_BLUETOOTH_SCO / TYPE_BLUETOOTH_A2DP )
when we don't plug in anything, it should return 2 (TYPE_BUILTIN_SPEAKER)
By the way,
1.
I guess the situation is same in XZ2 / XZ3....
Those are your Flagship models.
It is a little funny there are some problem in your Flagship models.
They should be best!
2.
There are so many user reports since 2015 say that
"Microphone is not working when set the speaker on"
(That means the other guy couldn't listen my voice)
App programers have to reset the speaker automatically so that the microphone could be normal.
I guess that there are also some problem in your "AudioRecord" firmware.
Try to take a good look at your audio-related firmware from beginning to end.
AudioManager am = (AudioManager) self.getSystemService(Context.AUDIO_SERVICE);
if (am != null) {
am.setSpeakerphoneOn(!am.isSpeakerphoneOn());
am.setSpeakerphoneOn(!am.isSpeakerphoneOn());
am.setSpeakerphoneOn(!am.isSpeakerphoneOn());
am.setSpeakerphoneOn(!am.isSpeakerphoneOn());
}Reference
1. Android official site
https://developer.android.com/reference/android/media/AudioDeviceInfo
2.. Android AudioDeviceInfo class
/**
* A device type describing the attached earphone speaker.
*/
public static final int TYPE_BUILTIN_EARPIECE = 1;
/**
* A device type describing the speaker system (i.e. a mono speaker or stereo speakers) built
* in a device.
*/
public static final int TYPE_BUILTIN_SPEAKER = 2;
/**
* A device type describing a headset, which is the combination of a headphones and microphone.
*/
public static final int TYPE_WIRED_HEADSET = 3;
/**
* A device type describing a pair of wired headphones.
*/
public static final int TYPE_WIRED_HEADPHONES = 4;
/**
* A device type describing an analog line-level connection.
*/