Does anyone know a good way of programmaticaly checking if an Android device, phone or tablet, has voice capabilities? By voice capabilities I mean capability to make phone call
In theory, you should be able to use Intent.resolveActivity
to do this. There's a problem (described here) with Galaxy tabs in particular. They evidently report that they have calling capability. You can even resolve an intent successfully. Unfortunately, it resolves to a no-op activity.
I would assume that prepare() would fail if there is not mic available:
mRecorder = new MediaRecorder();
mRecorder.setAudioSource(MediaRecorder.AudioSource.MIC);
mRecorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
mRecorder.setOutputFile(audio_file);
mRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
try {
mRecorder.prepare();
mRecorder.start();
} catch (Exception e) {}
I know this question was posted a long time ago, but I still thought I would post the solution I came up with that works for me so far, just so anyone with the same problem can benefit. (Because it seems like lots of people are having trouble finding a solution).
I just checked for the device's voicemail number, and obviously if it doesn't have one, then it is not a phone. In my code, to check this, it is tm.getVoiceMailNumber();
Here's what I did:
callButton.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
TelephonyManager tm = (TelephonyManager)getSystemService(TELEPHONY_SERVICE);
String ableToMakePhoneCalls = tm.getVoiceMailNumber(); //check device for voicemail number (null means no voicemail number).
if(ableToMakePhoneCalls == null){ //If the device does not have voicemail, then it must not be a phone. So it can't call.
//I displayed an alert dialog box here
}
else{
String phoneNum = "tel:8885554444";
Intent intentPhone = new Intent(android.content.Intent.ACTION_CALL);
intentPhone.setData(Uri.parse(phoneNum));
startActivity(intentPhone);
}
}
});
I haven't tried this myself, but it looks like the details you need would be in the TelephonyManager:
private boolean hasPhoneAbility()
{
TelephonyManager telephonyManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
if(telephonyManager.getPhoneType() == TelephonyManager.PHONE_TYPE_NONE)
return false;
return true;
}