Salut,
je veut envoyer un message a plusieurs numéros
erreur logcat:
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91 package com.formation.cimsp; import android.app.ListActivity; import android.content.Intent; import android.database.Cursor; import android.os.Bundle; import android.telephony.gsm.SmsManager; import android.view.Menu; import android.view.MenuItem; import android.widget.ListView; import android.widget.SimpleCursorAdapter; import android.widget.Toast; public class Contact_reun extends ListActivity { DBAdapter db; public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.liste); getListView().setOnCreateContextMenuListener(this); db = new DBAdapter(this); db.open(); DataBind(); } protected void onDestroy() { db.close(); super.onDestroy(); } public void DataBind(){ Cursor c = db.recupererLaListeDesCorrespondant(); startManagingCursor(c); SimpleCursorAdapter adapter = new SimpleCursorAdapter(this, R.layout.liste_item1,c,new String[]{"nom","prenom","telephone"}, new int[]{R.id.nom,R.id.prenom,R.id.telephone}); setListAdapter(adapter); } public boolean onCreateOptionsMenu(Menu menu) { menu.add(0,100,0,"Envoyer"); return true; } public boolean onOptionsItemSelected(MenuItem item) { Intent thisIntent = getIntent(); String ordre = thisIntent.getExtras().getString("ordre"); String lieu = thisIntent.getExtras().getString("lieu"); String date = thisIntent.getExtras().getString("heure"); String heure= thisIntent.getExtras().getString("heure"); switch(item.getItemId()){ case 100: final ListView list = getListView(); for (int i=0; i< getListAdapter().getCount();i++ ){ Cursor cursor = (Cursor)list.getAdapter().getItem(i); String nom = cursor.getString(cursor.getColumnIndex("nom")); String prenom = cursor.getString(cursor.getColumnIndex("prenom")); String telephone = cursor.getString(cursor.getColumnIndex("telephone")); String msg=("\nObjet: Convocation réunion du "+ordre+".\n" +"Lieu: "+lieu+".\n" +"Sujet: "+ordre+".\n" +"Monsieur(Madame),\n" +"Nous avons une réunion le "+date+"à partir de "+heure+".\n" +"Recevez Monsieur(Madam) ,nos salutation distinguées."); SmsManager.getDefault().sendTextMessage(telephone, null, msg,null, null); Toast.makeText(getApplicationContext(),"Mesage envoyer à "+nom+" "+ prenom, Toast.LENGTH_SHORT).show(); telephone=null; } break; } return false; } }
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 06-08 22:35:26.639: ERROR/AndroidRuntime(742): Uncaught handler: thread main exiting due to uncaught exception 06-08 22:35:26.659: ERROR/AndroidRuntime(742): java.lang.NullPointerException 06-08 22:35:26.659: ERROR/AndroidRuntime(742): at android.telephony.gsm.SmsManager.sendTextMessage(SmsManager.java:79) 06-08 22:35:26.659: ERROR/AndroidRuntime(742): at com.formation.cimsp.Contact_reun.onOptionsItemSelected(Contact_reun.java:80) 06-08 22:35:26.659: ERROR/AndroidRuntime(742): at android.app.Activity.onMenuItemSelected(Activity.java:2085) 06-08 22:35:26.659: ERROR/AndroidRuntime(742): at com.android.internal.policy.impl.PhoneWindow.onMenuItemSelected(PhoneWindow.java:820) 06-08 22:35:26.659: ERROR/AndroidRuntime(742): at com.android.internal.view.menu.MenuItemImpl.invoke(MenuItemImpl.java:139) 06-08 22:35:26.659: ERROR/AndroidRuntime(742): at com.android.internal.view.menu.MenuBuilder.performItemAction(MenuBuilder.java:813) 06-08 22:35:26.659: ERROR/AndroidRuntime(742): at com.android.internal.view.menu.IconMenuView.invokeItem(IconMenuView.java:519) 06-08 22:35:26.659: ERROR/AndroidRuntime(742): at com.android.internal.view.menu.IconMenuItemView.performClick(IconMenuItemView.java:122) 06-08 22:35:26.659: ERROR/AndroidRuntime(742): at android.view.View.onTouchEvent(View.java:3828) 06-08 22:35:26.659: ERROR/AndroidRuntime(742): at android.widget.TextView.onTouchEvent(TextView.java:6291) 06-08 22:35:26.659: ERROR/AndroidRuntime(742): at android.view.View.dispatchTouchEvent(View.java:3368) 06-08 22:35:26.659: ERROR/AndroidRuntime(742): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:863) 06-08 22:35:26.659: ERROR/AndroidRuntime(742): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:863) 06-08 22:35:26.659: ERROR/AndroidRuntime(742): at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:1691) 06-08 22:35:26.659: ERROR/AndroidRuntime(742): at android.view.ViewRoot.handleMessage(ViewRoot.java:1525) 06-08 22:35:26.659: ERROR/AndroidRuntime(742): at android.os.Handler.dispatchMessage(Handler.java:99) 06-08 22:35:26.659: ERROR/AndroidRuntime(742): at android.os.Looper.loop(Looper.java:123) 06-08 22:35:26.659: ERROR/AndroidRuntime(742): at android.app.ActivityThread.main(ActivityThread.java:3948) 06-08 22:35:26.659: ERROR/AndroidRuntime(742): at java.lang.reflect.Method.invokeNative(Native Method) 06-08 22:35:26.659: ERROR/AndroidRuntime(742): at java.lang.reflect.Method.invoke(Method.java:521) 06-08 22:35:26.659: ERROR/AndroidRuntime(742): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:782) 06-08 22:35:26.659: ERROR/AndroidRuntime(742): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:540) 06-08 22:35:26.659: ERROR/AndroidRuntime(742): at dalvik.system.NativeStart.main(Native Method) 06-08 22:35:30.780: ERROR/TextView(750): Saved cursor position 2/2 out of range for (restored) text
Partager