I solved the problem and I've found a google group of related topic. It was really helpful. Here's the link:
https://groups.google.com/forum/#!topic/android-ndk/O-hufEm20cU
I tested it in the native-audio example provided with android NDK. You've to take interface of android configuration first and then set stream type to STREAM_VOICE after creating the audio player.
// Code for working with ear speaker by setting stream type to STREAM_VOICE
SLAndroidConfigurationItf playerConfig;
result = (*bqPlayerObject)->GetInterface(bqPlayerObject, SL_IID_ANDROIDCONFIGURATION, &playerConfig);
SLint32 streamType = SL_ANDROID_STREAM_VOICE;
result = (*playerConfig)->SetConfiguration(playerConfig, SL_ANDROID_KEY_STREAM_TYPE, &streamType, sizeof(SLint32));
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…