I am trying to send as SMS the data from the database of my Server API. Phone number from the database is used to login the app. Once logged in, a SMS will automatically send to the phone number.
Login class:
String phoneNum = et_mobile.getText().toString();
int mobile = Integer.parseInt(phoneNum.trim());
SmsManager smsManager = SmsManager.getSmsManagerForSubscriptionId(mobile);
String spamMessage = "Srno: " + resObj.getSrNo() +
"Date: " + resObj.getDate() +
"In: " + resObj.getTimeIn() +
"Out: " + resObj.getTimeOut() +
"JO#: " + resObj.getJoNo() +
"CoPer: " + resObj.getContactPerson() +
"BR: " + resObj.getDesignation() +
"CNum: " + resObj.getContactNo();
ArrayList<String> sms;
sms = smsManager.divideMessage(spamMessage);
smsManager.sendMultipartTextMessage(phoneNum, null,sms,null, null);
I already used these permission in my manifest:
<uses-permission android:name="android.permission.READ_SMS" />
<uses-permission android:name="android.permission.RECEIVE_SMS" />
<uses-permission android:name="android.permission.READ_CONTACTS" />
<uses-permission android:name="android.permission.READ_PHONE_STATE"/>
<uses-permission android:name="android.permission.SEND_SMS"/>
When I login my logcat shows this:
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.android.ras, PID: 18982
java.lang.NumberFormatException: For input string: "09xxxxxxxxx"
and I don't receive any SMS.