Я пытаюсь отправить SMS с помощью SmsManager
для какого-то устройства, оно отправляет SMS, для другого устройства происходит сбой приложения.Мое устройство не выходит из строя, но на клиентском устройстве оно есть.
Мой код:
private void sendMessage() {
if (ContextCompat.checkSelfPermission(getApplicationContext(), Manifest.permission.SEND_SMS) == PackageManager.PERMISSION_GRANTED) {
SmsManager smsManager = SmsManager.getDefault();
smsManager.sendMultipartTextMessage(mobileNumber, null, smsManager.divideMessage(msg), null, null);
Snackbar.make(findViewById(android.R.id.content), "Message Sent",
Snackbar.LENGTH_SHORT).show();
} else {
String requestPermissionArray[] = {Manifest.permission.SEND_SMS};
ActivityCompat.requestPermissions(this, requestPermissionArray, PERMISSION_REQUEST_CODE_SEND_SMS);
}
}
@Override
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions,
@NonNull int[] grantResults) {
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
if (grantResults[0] == PackageManager.PERMISSION_GRANTED) {
switch (requestCode) {
case PERMISSION_REQUEST_CODE_SEND_SMS:
sendMessage();
break;
}
}
}
AndroidManifest.xml
<uses-permission android:name="android.permission.SEND_SMS" />
Журналы аварий, которые я получил в Crashlytics
1
Caused by java.lang.SecurityException
at android.os.Parcel.createException(Parcel.java:1950)
at android.os.Parcel.readException(Parcel.java:1918)
at android.os.Parcel.readException(Parcel.java:1868)
at com.android.internal.telephony.ISms$Stub$Proxy.isImsSmsSupportedForSubscriber(ISms.java:1422)
at android.telephony.SmsManager.isImsSmsSupported(SmsManager.java:1410)
at android.telephony.SmsMessage.useCdmaFormatForMoSms(SmsMessage.java:841)
at android.telephony.SmsMessage.useCdmaFormatForMoSms(SmsMessage.java:827)
at android.telephony.SmsMessage.fragmentText(SmsMessage.java:373)
at android.telephony.SmsManager.divideMessage(SmsManager.java:603)
at in.onlineneta.app.ui.activity.VoterDetailsActivity.sendMessage(VoterDetailsActivity.java:640)
at in.onlineneta.app.ui.activity.VoterDetailsActivity.onRequestPermissionsResult(VoterDetailsActivity.java:806)
at android.app.Activity.dispatchRequestPermissionsResult(Activity.java:7630)
at android.app.Activity.dispatchActivityResult(Activity.java:7480)
at android.app.ActivityThread.deliverResults(ActivityThread.java:4489)
at android.app.ActivityThread.handleSendResult(ActivityThread.java:4538)
at android.app.servertransaction.ActivityResultItem.execute(ActivityResultItem.java:49)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1906)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:6863)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:537)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
2
Fatal Exception: java.lang.RuntimeException: Failure delivering result ResultInfo{who=@android:requestPermissions:, request=2246, result=-1, data=Intent { act=android.content.pm.action.REQUEST_PERMISSIONS (has extras) }} to activity {in.onlineneta.app/in.onlineneta.app.ui.activity.VoterDetailsActivity}: java.lang.SecurityException
at android.app.ActivityThread.deliverResults(ActivityThread.java:4496)
at android.app.ActivityThread.handleSendResult(ActivityThread.java:4538)
at android.app.servertransaction.ActivityResultItem.execute(ActivityResultItem.java:49)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1906)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:6863)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:537)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)