SMS Manager envía mensaje mutlipart cuando hay menos de 160 caracteres
Escribo una aplicación que utiliza SMS Manager. Utilizo el método sendTextMessage()
pero no es trabajo. Ahora estoy usando sendMutlipartTextMessage()
y es trabajo. Pero es enviar mensaje de varias partes cuando se trata de unos 60 caracteres. ¿Esto es normal? En todas partes leo más de 160 caracteres. Esto es importante para mí porque debo pagar más.
- Encontrar datamessage en el teléfono android antes de instalar la aplicación
- Recibir SMS Intent: Obtener identificación de mensaje o de hilo
- Informe de entrega de Android SmsManger
- Android: SMSManager - Intento de obtener longitud de matriz nula
- Enviar SMS sin guardarlo en el elemento enviado en kitkat
- Abortar SMS Intent en Android KitKat
- SMS GENERIC FAILURE en teléfonos Dual Sim Android
- Eliminar SMS de android en 4.4.4 (Afectado filas = 0 (cero), después de suprimido)
- ¿Cómo puedo enviar mensajes SMS en el BACKGROUND usando Android?
- Administrador de sms de Android no envía sms
- Cómo abortar BroadcastReceiver en android
- SendMultipartTextMessage y monitor enviar y recibir
- ¿Cómo enviar un SMS usando SMSmanager en Dual SIM móvil?
El límite de caracteres de mensaje depende del tamaño de bit de caracteres del alfabeto que esté utilizando. Para el alfabeto estándar de GSM de 7 bits, el límite de caracteres es 160. Para un alfabeto de 8 bits, es 140, y para un alfabeto de 16 bits, que suena como su situación, es sólo de 70 caracteres. Si tiene que enviar mensajes con caracteres Unicode especiales, como los que se encuentran en alfabetos no latinos, entonces está atascado con el alfabeto de 16 bits y su límite de 70 caracteres. Si de alguna manera puede convertir los mensajes en el alfabeto básico de 7 bits, tendrá el límite de 160 caracteres.
Añado mi método de SMS si puede ayudar a alguien.
// TO USE EveryWhere
SMSUtils.sendSMS(context, phoneNumber, message);
//Manifiesto
<!-- SMS --> <uses-permission android:name="android.permission.SEND_SMS"/> <uses-permission android:name="android.permission.READ_PHONE_STATE"/> <receiver android:name=".SMSUtils" android:enabled="true" android:exported="true"> <intent-filter> <action android:name="SMS_SENT"/> <action android:name="SMS_DELIVERED"/> </intent-filter> </receiver>
//JAVA
public class SMSUtils extends BroadcastReceiver { public static final String SENT_SMS_ACTION_NAME = "SMS_SENT"; public static final String DELIVERED_SMS_ACTION_NAME = "SMS_DELIVERED"; @Override public void onReceive(Context context, Intent intent) { //Detect l'envoie de sms if (intent.getAction().equals(SENT_SMS_ACTION_NAME)) { switch (getResultCode()) { case Activity.RESULT_OK: // Sms sent Toast.makeText(context, context.getString(R.string.sms_send), Toast.LENGTH_LONG).show(); break; case SmsManager.RESULT_ERROR_GENERIC_FAILURE: // generic failure Toast.makeText(context, context.getString(R.string.sms_not_send), Toast.LENGTH_LONG).show(); break; case SmsManager.RESULT_ERROR_NO_SERVICE: // No service Toast.makeText(context, context.getString(R.string.sms_not_send_no_service), Toast.LENGTH_LONG).show(); break; case SmsManager.RESULT_ERROR_NULL_PDU: // null pdu Toast.makeText(context, context.getString(R.string.sms_not_send), Toast.LENGTH_LONG).show(); break; case SmsManager.RESULT_ERROR_RADIO_OFF: //Radio off Toast.makeText(context, context.getString(R.string.sms_not_send_no_radio), Toast.LENGTH_LONG).show(); break; } } //detect la reception d'un sms else if (intent.getAction().equals(DELIVERED_SMS_ACTION_NAME)) { switch (getResultCode()) { case Activity.RESULT_OK: Toast.makeText(context, context.getString(R.string.sms_receive), Toast.LENGTH_LONG).show(); break; case Activity.RESULT_CANCELED: Toast.makeText(context, context.getString(R.string.sms_not_receive), Toast.LENGTH_LONG).show(); break; } } } /** * Test if device can send SMS * @param context * @return */ public static boolean canSendSMS(Context context) { return context.getPackageManager().hasSystemFeature(PackageManager.FEATURE_TELEPHONY); } public static void sendSMS(final Context context, String phoneNumber, String message) { if (!canSendSMS(context)) { Toast.makeText(context, context.getString(R.string.cannot_send_sms), Toast.LENGTH_LONG).show(); return; } PendingIntent sentPI = PendingIntent.getBroadcast(context, 0, new Intent(SENT_SMS_ACTION_NAME), 0); PendingIntent deliveredPI = PendingIntent.getBroadcast(context, 0, new Intent(DELIVERED_SMS_ACTION_NAME), 0); final SMSUtils smsUtils = new SMSUtils(); //register for sending and delivery context.registerReceiver(smsUtils, new IntentFilter(SMSUtils.SENT_SMS_ACTION_NAME)); context.registerReceiver(smsUtils, new IntentFilter(DELIVERED_SMS_ACTION_NAME)); SmsManager sms = SmsManager.getDefault(); ArrayList<String> parts = sms.divideMessage(message); ArrayList<PendingIntent> sendList = new ArrayList<>(); sendList.add(sentPI); ArrayList<PendingIntent> deliverList = new ArrayList<>(); deliverList.add(deliveredPI); sms.sendMultipartTextMessage(phoneNumber, null, parts, sendList, deliverList); //we unsubscribed in 10 seconds new Handler().postDelayed(new Runnable() { @Override public void run() { context.unregisterReceiver(smsUtils); } }, 10000); } }
- Código extrae versionName incorrecto de manifiesto
- ¿Cómo especifico el título del icono de la pantalla de inicio de mi aplicación?