[If someone still stumbles, looking for this still existing century-old solution]
AFAIK, TelephonyManager.getLine1Number () is not reliable due to various operator restrictions. There are some Java-based hackers that vary from device to device, which makes these hacks useless [at least in terms of supported models]
But there is legitimate legitimate logic to find the number if you really need it. Request all sms SMS providers and get the number "To".
Additional advantages of this trick: 1. You can get all line numbers if there are several simulators on the device.
Cons: 1. you will need SMS_READ permission [sorry for that] 2. You will receive all SIM numbers ever used in the device. this problem can be minimized with some restriction logic, for example. time frames (SMS, received or sent only today), etc. It would be interesting to hear from others about how to improve this case.
Amit K. Saha
source share