Код: Выделить всё
Fatal Exception: java.lang.NullPointerException: Attempt to invoke virtual method 'int java.lang.String.length()' on a null object reference
at android.os.Parcel.createExceptionOrNull(Parcel.java:3263)
at android.os.Parcel.createException(Parcel.java:3241)
at android.os.Parcel.readException(Parcel.java:3224)
at android.os.Parcel.readException(Parcel.java:3166)
at com.android.internal.telephony.ISms$Stub$Proxy.sendTextForSubscriber(ISms.java:1954)
at android.telephony.SmsManager$1.onSuccess(SmsManager.java:772)
at android.telephony.SmsManager.sendResolverResult(SmsManager.java:1822)
at android.telephony.SmsManager.resolveSubscriptionForOperation(SmsManager.java:1783)
at android.telephony.SmsManager.sendTextMessageInternal(SmsManager.java:767)
at android.telephony.SmsManager.sendTextMessage(SmsManager.java:600)
at com.app.utils.DeviceBindingHelper.sendSMS$lambda$4(DeviceBindingHelper.kt:173)
< /code>
Inside DeviceBindingHelper.sendsms У меня есть следующий код < /p>
val sms = SmsManager.getSmsManagerForSubscriptionId(it[0].subscriptionId)
sms.sendTextMessage(phoneNumber, null, message, sentPI, deliveredPI)
Код: Выделить всё
private void sendTextMessageInternal(String destinationAddress, String scAddress,
String text, PendingIntent sentIntent, PendingIntent deliveryIntent,
boolean persistMessage, String packageName, String attributionTag, long messageId) {
if (TextUtils.isEmpty(destinationAddress)) {
throw new IllegalArgumentException("Invalid destinationAddress");
}
if (TextUtils.isEmpty(text)) {
throw new IllegalArgumentException("Invalid message body");
}
// We will only show the SMS disambiguation dialog in the case that the message is being
// persisted. This is for two reasons:
// 1) Messages that are not persisted are sent by carrier/OEM apps for a specific
// subscription and require special permissions. These messages are usually not sent by
// the device user and should not have an SMS disambiguation dialog associated with them
// because the device user did not trigger them.
// 2) The SMS disambiguation dialog ONLY checks to make sure that the user has the SEND_SMS
// permission. If we call resolveSubscriptionForOperation from a carrier/OEM app that has
// the correct MODIFY_PHONE_STATE or carrier permissions, but no SEND_SMS, it will throw
// an incorrect SecurityException.
if (persistMessage) {
resolveSubscriptionForOperation(new SubscriptionResolverResult() {
@Override
public void onSuccess(int subId) {
ISms iSms = getISmsServiceOrThrow();
try {
iSms.sendTextForSubscriber(subId, packageName, attributionTag,
destinationAddress, scAddress, text, sentIntent, deliveryIntent,
persistMessage, messageId);
} catch (RemoteException e) {
Log.e(TAG, "sendTextMessageInternal: Couldn't send SMS, exception - "
+ e.getMessage() + " " + formatCrossStackMessageId(messageId));
notifySmsError(sentIntent, RESULT_REMOTE_EXCEPTION);
}
}
@Override
public void onFailure() {
notifySmsError(sentIntent, RESULT_NO_DEFAULT_SMS_APP);
}
});
} else {
// Not persisting the message, used by sendTextMessageWithoutPersisting() and is not
// visible to the user.
ISms iSms = getISmsServiceOrThrow();
try {
iSms.sendTextForSubscriber(getSubscriptionId(), packageName, attributionTag,
destinationAddress, scAddress, text, sentIntent, deliveryIntent,
persistMessage, messageId);
} catch (RemoteException e) {
Log.e(TAG, "sendTextMessageInternal (no persist): Couldn't send SMS, exception - "
+ e.getMessage() + " " + formatCrossStackMessageId(messageId));
notifySmsError(sentIntent, RESULT_REMOTE_EXCEPTION);
}
}
}
Это сбой связан с чем -то изменяющим>
Подробнее здесь: https://stackoverflow.com/questions/796 ... -sendtextf