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); } } });
source share