Bonjour Cher Développeur,

je développe une application Android pour l'envoi des SMS (un sms contient plus de 160 caractères ).

Pour ce qui concerne l'envoi, ça marche sans problème. Mais lorsque je n'ai pas suffisamment de crédits, pour l'envoi de l'SMS, je ne recois pas un rapport. le système d'envoi plante, ainsi, je n'arrive pas a envoyer un SMS depuis l'application native d'sms d'Android. Il faut pour cela redémarrer mon appareil afin de pouvoir envoyer un SMS.

j'aimerais avoir un retour selon lequel je saurai que je n'ai pas suffisamment de crédit pour cette opération à travers les Intents
voici mon code :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
@SuppressWarnings({ "deprecation", "deprecation" })
public  void sendSMS(String message, String phoneNumber)
    {
        String SENT = "SMS_SENT";
        String DELIVERED = "SMS_DELIVERED";
 
        ArrayList<PendingIntent> sentPendingIntents = new ArrayList<PendingIntent>();
        ArrayList<PendingIntent> deliveredPendingIntents = new ArrayList<PendingIntent>();
 
        PendingIntent sentPI = PendingIntent.getBroadcast(this, 0,
                new Intent(SENT), 0);
 
        PendingIntent deliveredPI = PendingIntent.getBroadcast(this, 0,
                new Intent(DELIVERED), 0);
 
        registerReceiver(new BroadcastReceiver() {
 
            @SuppressWarnings("deprecation")
            @Override
            public void onReceive(Context arg0, Intent arg1) {
                // TODO Auto-generated method stub
                switch(getResultCode())
                {
                    case Activity.RESULT_OK:
 
                        display("SUCCES:TRANSFERT VALIDE.");
 
                        mp_smssend.start();//jouer un sont d'envoi reussi !
                    break;
                    case SmsManager.RESULT_ERROR_GENERIC_FAILURE:
                        display("Generic failure");
                    break;
                    case SmsManager.RESULT_ERROR_NO_SERVICE:
                        display("No Service");
                    break;
                    case SmsManager.RESULT_ERROR_NULL_PDU:
                    display("Null PDU");
                    break;
                    case SmsManager.RESULT_ERROR_RADIO_OFF:
                        display("Radio off");
                    break;                 
                }
 
            }
        }, new IntentFilter(SENT));
 
 
        registerReceiver(new BroadcastReceiver() {
 
            @Override
            public void onReceive(Context context, Intent intent) {
                // TODO Auto-generated method stub
                switch(getResultCode())
                {
                    case Activity.RESULT_OK:
                        display("Merci et à bientot ");
                    break;
                    case Activity.RESULT_CANCELED:
                        display("Problème de réseau veuillez réessayer");
                    break;         
                }
            }
        }, new IntentFilter(DELIVERED));
 
        SmsManager sms = SmsManager.getDefault() ;
        ArrayList<String> msgStringArray = sms.divideMessage(message);
 
        for (int number=0; number<msgStringArray.size();number++)
        {
            sentPendingIntents.add(sentPI);
            deliveredPendingIntents.add(deliveredPI);
 
        }
        sms.sendMultipartTextMessage(phoneNumber, null, msgStringArray,  sentPendingIntents, deliveredPendingIntents); 
    }
Pour l'instant je reçois une alerte que l'ai placé des le cas ci-dessous entre 15 à 20 minutes après de l’opération (trop long) :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
case SmsManager.RESULT_ERROR_GENERIC_FAILURE:
display("Generic failure");
break;
j'aimerais avoir un rapport aussi tôt que l’opération échoue.

Merci.