How to get Mobile sim number(GSM) in android -
i developing android application. in need user mobile sim number calling purposes automatically. facing problem in getting mobile number of user. have tried this.
telephonymanager telemamanger = (telephonymanager) getsystemservice(context.telephony_service); string getsimserialnumber = telemamanger.getsimserialnumber(); string deviceid = telemamanger.getdeviceid(); string getsimnumber = telemamanger.getline1number();
and
telephonymanager tm = (telephonymanager) this.getsystemservice(context.telephony_service); string network; connectivitymanager cm = (connectivitymanager) this.getsystemservice(context.connectivity_service); if(cm.getactivenetworkinfo().gettypename().equals("mobile")) network = "cellnetwork/4g"; else if(cm.getactivenetworkinfo().gettypename().equals("wifi")) network = "wifi"; else network ="na"; string uphone = tm.getline1number(); toast.maketext(getapplicationcontext(),uphone+" "+network,toast.length_long).show();
in these, getting information want except mobile number. there alternate method mobile number in bhim app. in bhim app getting mobile numbers automatically(whether single or dual sim).
sure!
these informations can both on subscriptionmanager , subscriptioninfo.
though i'm not sure on permissions need on 3rd party app. how on company's framework:
private void fillsimnumber(telephonymanager tm, subscriptioninfo subscriptioninfo) { final string rawnumber = tm.getline1number(subscriptioninfo.getsubscriptionid()); if (!textutils.isempty(rawnumber)) { msimnumber.settext(rawnumber); } }
best of luck!
Comments
Post a Comment