Bonjour,
J'essai d'envoyer des SMS, via smsmanager (sms long).
Je souhaite écrire une fonction qui doit me renvoyer true si le sms est envoyé et false dans le cas contraire (donc utilisation de pendingIntent).
Voila ce que j'ai écrit pour le moment :
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
 
import android.os.Bundle;
import android.app.Activity;
import android.telephony.SmsManager;
import java.util.ArrayList;
import android.content.BroadcastReceiver;
import android.app.PendingIntent;
import android.widget.Toast;
import android.content.Context;
 
public static boolean sendLongSms(String recipient,String message)
{
	//Set pending intent		
	String SENT = "SMS_SENT";
	SmsManager smsManager = SmsManager.getDefault();
	ArrayList<String> msgArray = smsManager.divideMessage(message);
	Toast.makeText(getContexteApplication(),msgArray.size(),Toast.LENGTH_LONG).show();
	ArrayList<PendingIntent> sentIntents = new ArrayList<PendingIntent>();
	for (int i=0; i<msgArray.size(); i++)
	{
		sentIntents.add(PendingIntent.getBroadcast(getApplicationContext(),0,new Intent(SENT),PendingIntent.FLAG_UPDATE_CURRENT));
	}
 
	//Register for sent
	registerReceiver(new BroadcastReceiver(){
		@Override
		public void onReceive(Context context, Intent intent)
		{
			String result = "";
			switch (getResultCode()) {
				case Activity.RESULT_OK:
				result = "Ok";
				break;
				default :
				result = "Error";
				break;
			}
			Toast.makeText(getContexteApplication(),result,Toast.LENGTH_LONG).show();
		}
	}, new IntentFilter(SENT));
 
	//Send SMS
	smsManager.sendMultipartTextMessage(recipient,null,msgArray,sentIntents,null);
	return true;
}
Lorsque je lance la fonction sur le terminal Android, j'ai l'erreur suivante :
Erreur interne du framework
: String ressource ID #0*9

Merci de votre aide.

Ps : je suis extrêmement novice en Java