manager.setSpeakerphoneOn(true);
works for mobile phones but does not works for tablet. The sound does not plays from the speaker. Does anybody knows why? Please Help
MODIFY_AUDIO_SETTINGS permission is also added in Manifest file.
My code
Path for the audio file String mainpath = "android.resource://com.example.texttospeech/raw/";
public void makeSound(String amount) {
AudioManager m_amAudioManager;
m_amAudioManager = (AudioManager)getSystemService(Context.AUDIO_SERVICE);
m_amAudioManager.setMode(AudioManager.MODE_CURRENT);
m_amAudioManager.setSpeakerphoneOn(true);
int numInput = Integer.parseInt(amount);
String amt = amount;
Log.d("The amount is : ", amt);
int length = amt.length();
Log.d("Length of the String : ", Integer.toString(length));
thousandsDigit = numInput / 1000;
ths = numInput % 1000;
hundredsDigit = ths / 100;
hs = ths % 100;
tensDigit = hs / 10;
onesDigit = hs % 10;
System.out.println(thousandsDigit);
System.out.println(hundredsDigit);
System.out.println(tensDigit);
System.out.println(onesDigit);
Log.d("Transaction type:",transactionType);
if (transactionType.equals("WITHDRAW")){
// withdraw();
final MediaPlayer mp11 = new MediaPlayer();
try {
mp11.setDataSource(AgentTransaction.this,
Uri.parse(mainpath + "withdraw"));
mp11.prepare();
} catch (IllegalArgumentException | SecurityException
| IllegalStateException | IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
mp11.start();
mp11.setOnCompletionListener(new MediaPlayer.OnCompletionListener() {
@Override
public void onCompletion(MediaPlayer mp) {
mp11.release();
}
});
}
}