How to check if an Android device has voice capabilities

Does anyone know a good way to programmatically check if the Android-powered device support, phone or tablet voice capabilities? Thanks to the capabilities of voice, I mean the possibility to make phone calls. I know that there are devices such as the Galaxy Tab in North America who do not have this capability.

+4
source share
4 answers

I have not tried this myself, but it looks like the data you need will be in TelephonyManager:

private boolean hasPhoneAbility() { TelephonyManager telephonyManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE); if(telephonyManager.getPhoneType() == TelephonyManager.PHONE_TYPE_NONE) return false; return true; } 
+3
source

I know that this issue has been published a long time ago, but I still thought that it would publish a decision that I came to work for me so far, so anyone who has the same problem can benefit. (Because it seems that many people can not find a solution).

I just checked the voice mail device number, and, obviously, if it does not, then it is not a phone. In my code to test it, it tm.getVoiceMailNumber();

Here is 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); } } }); TELEPHONY_SERVICE); 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); } } }); means no voicemail number). 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); } } }); If the device does not have voicemail, then it must not be a phone. 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); } } }); ; 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); } } }); 
+1
source

In theory, you should use Intent.resolveActivity for this. There the problem (described herein ) with a Galaxy tabs in particular. Obviously, they report that they have the ability to call. You can even successfully solved intention. Unfortunately, he allows no-op operation.

0
source

I would suggest that prepare () will fail if there is no access to the microphone:

  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) {} 
0
source

All Articles