1

I want to send SIM details through sms, I am using this code (given below) but it is not working (sms is not being sent), I am not getting any error or exception. Please tell what is the problem?

Code:

SmsManager smsManager = SmsManager.getDefault();

String simDetails = "Your device's SIM Details Are:\n"+"\nDevice ID: "+telephony.getDeviceId()+"\nSubscriber ID: "+telephony.getSubscriberId()
                +"\nSIM Serial Number: "+telephony.getSimSerialNumber()+"\nNetwork Operator: "+telephony.getNetworkOperator()+"\nNetwork Operator Name: "+telephony.getNetworkOperatorName()
                +"\nNetwork Country: "+telephony.getNetworkCountryIso()+"\nSIM Country: "+telephony.getSimCountryIso()+"\nSIM Operator: "+telephony.getSimOperator()+"\nSIM Operator Name: "+telephony.getSimOperatorName()
                +"\nSoftware Version: "+telephony.getDeviceSoftwareVersion()+"\nGroup Id Level-1: "+telephony.getGroupIdLevel1()+"\nMMS UAP: "+telephony.getMmsUAProfUrl()+"\nMMS User Agent: "+telephony.getMmsUserAgent()
                +"\nVoice Mail Tag: "+telephony.getVoiceMailAlphaTag()+"\nVoice Mail Number: "+telephony.getVoiceMailNumber()+"\nLine-1 Number: "+telephony.getLine1Number()+"SIM Location: "+telephony.getCellLocation();

smsManager.sendTextMessage("receiver's number", null, simDetails, null, null);
manfcas
  • 1,933
  • 7
  • 28
  • 47
Sajal Ali
  • 427
  • 1
  • 10
  • 21
  • 1
    Provided that you do have the necessary permission, and aren't ignoring a caught Exception somewhere, it looks like your problem is just that the text you're sending is too long for `sendTextMessage()`. You'll need to split it, and use `sendMultipartTextMessage()`. – Mike M. Feb 05 '17 at 21:42

1 Answers1

0

Make sure you have Read and send SMS permission(Marshmallow >=)

Manifest.permission.RECEIVE_SMS
ActivityCompat.checkSelfPermission(context,Manifest.permission.RECEIVE_SMS);
Ajay Shrestha
  • 2,433
  • 1
  • 21
  • 25