I am trying to check if the device has telephony feature or not. But in emulator, it is always returning false. Why is it so? Am I doing something wrong.
Asked
Active
Viewed 1,920 times
3
-
is this your code? pm.hasSystemFeature(PackageManager.FEATURE TELEPHONY); returning false ??? its always returning false. – Padma Kumar Oct 16 '12 at 13:45
-
I'm doing this: boolean hasTelephony=pm.hasSystemFeature(PackageManager.FEATURE_TELEPHONY); and for emulator it is returning false – Rookie Oct 16 '12 at 13:48
-
http://stackoverflow.com/q/6465125/1012284 – Padma Kumar Oct 16 '12 at 13:51
-
I am having the same issue. Did you find any reason or solution? – A.J. Apr 25 '14 at 10:51
2 Answers
0
You can also connect to an emulator console to simulate an incoming voice call or SMS. For more information, see Telephony Emulation and SMS Emulation.
End of this page: https://developer.android.com/studio/run/emulator-networking
That is normal, your emulator does't call nor it sends sms (note that Telephony includes a lot of features)

IvanF.
- 513
- 10
- 18
-1
You can just wrap your code in try/catch. It works in all cases, even with the last api changes about sms sending.
try{
// code that use telephony features
}
catch(Exception e){
// code that doesn't use telephony features
}

quent
- 1,936
- 1
- 23
- 28