salut
je suis entrain de devloper une application android qui contient plusieurs activity
1) Info.java
2)hoteldatabase
3)Menu.java
mon probleme et le suivantes si je lance mon intent a partir de activity hoteldatabase.java
tous marche bien je récupérer mes extras et il sont afficher au niveau d activity Info.java
mais quand je lance l activity menu.java apartir de info.java
et puis j lance l activity info.java a partir de Menu.java les donneézs quit sont deja recuperer au niveau info.java sont perdu
aussi quelque soit l intent que j lance a partir de Info.java exmple CallIntent quand je termine l’opération Call je reviens automatiquement a mon activity Info.java je trouve les données récupérer par getextras perdu
mon question est le suivant il'ya t'il une solution pour ne pa perdu les extras recuperer dans une activity ????? aidez moi svp et
merci en avance

Hoteldatabase.java
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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
package com.tunisie.tourisme;
 
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
 
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.NameValuePair;
import org.apache.http.client.HttpClient;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.message.BasicNameValuePair;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
 
 
 
 
 
 
import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.BaseAdapter;
import android.widget.ListAdapter;
import android.widget.ListView;
import android.widget.SimpleAdapter;
import android.widget.Toast;
 
public class Hoteldatabase extends Activity  {
  //  private String result;
   // private ListView list;
	/** Called when the activity is first created. */    
	List<Map<String,Object>> res = new ArrayList<Map<String,Object>>();
	private String result;
	@Override
	public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.list);
        if (this.getIntent().getExtras() != null) {
			Bundle b10 = this.getIntent().getExtras();
			final String strderecherche = b10.getString("strValue");
 
			// String result = "";
 
 
			ArrayList<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>();
 
			  nameValuePairs.add(new BasicNameValuePair("nom",strderecherche));
 
 
 
				 InputStream is = null;
						// Envoie de la commande http
				 try{
                     HttpClient httpclient = new DefaultHttpClient();
 
                 HttpPost httppost = new HttpPost("http://testandroid.hebergratuit.com/base.php");
                 httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
                 HttpResponse response = httpclient.execute(httppost);
                 HttpEntity entity = response.getEntity();
                 is = entity.getContent();
 
                 }catch(Exception e){
                     Log.e("log_REMOTO", "Erreur connection http: "+e.toString());
 
 
 
 
                }
 
 
 
 
 
				  try{
                      BufferedReader reader = new BufferedReader(new InputStreamReader(is,"iso-8859-1"),8);
                  StringBuilder sb = new StringBuilder();
                  String line=null;
                  while ((line = reader.readLine()) != null) {
                                    sb.append(line + "\n");        
                  }
                  is.close();
                  result = sb.toString();
                  Log.i("log_tag",result);  
 
                 // if (result==null)    {Toast.makeText(Hoteldatabase.this, "pas de resultas",
						//Toast.LENGTH_LONG).show();
				 Log.i("log_tag",result);	 
			 }
 
 
 
                  catch(Exception e){
                            Log.e("log_tag", "resultat null: "+e.toString());
 
 
 
 
                 }
        }
 
 
 
 
 
        if (result ==null){finish();}   
 
 
				        try{
 
			           // JSONArray J = new JSONArray(result);
 
			                JSONArray jArray = new JSONArray(result);
			    			for(int i=0;i<jArray.length();i++){
			    				JSONObject json_data = jArray.getJSONObject(i);
 
			    			//	if (i <= 0 ) {
			    					//Toast.makeText(Hoteldatabase.this, "pas de resultas",
			    						//	Toast.LENGTH_LONG).show();
			    				//}
			    				 Map<String,Object> map = new HashMap<String,Object>();
			    				//JSONObject json_data = jArray.getJSONObject(i);
 
 
 
				                // Résultats de la requête
 
			    				 map.put("adresse",json_data.getString("adresse"));
			    				 map.put("urlimage",json_data.getString("urlimage"));
			    				 map.put("ville",json_data.getString("ville"));
			    				 map.put("cat",json_data.getString("cat"));
			    				 map.put("nom",json_data.getString("nom"));
			    				 map.put("tel",json_data.getString("tel"));
			    				 map.put("email",json_data.getString("email"));
			    				 map.put("urlgalimage",json_data.getString("urlgalimage"));
			    				 map.put("desc",json_data.getString("desc"));
			    				 map.put("site",json_data.getString("site"));
			    				 map.put("lat",json_data.getString("lat"));
			    				 map.put("log",json_data.getString("log"));
 
 
			    				 URL pictureURL = null;
			    					try {
			    						pictureURL = new URL(json_data.getString("urlimage") );
			    					} catch (MalformedURLException e1) {
			    						// TODO Auto-generated catch block
			    						e1.printStackTrace();
			    					}
			    		        	Bitmap bitmap = null;
			    					try {
			    						bitmap = BitmapFactory.decodeStream(pictureURL.openStream());
			    					} catch (IOException e1) {
			    						// TODO Auto-generated catch block
			    						e1.printStackTrace();
			    					}
			    				//	if (dadd.length() == 0) {
				    					//Toast.makeText(Hoteldatabase.this, "hhhhhhhhhhhhhhhhhg",
				    							//Toast.LENGTH_LONG).show();}
 
 
 
			    		        	map.put("img",bitmap);
 
				                //Log.i("log_tag",returnString += "\n\t" + jArray.getJSONObject(i));
			    				 res.add(map);
 
 
				            }
			    			}
 
		 catch(JSONException e){
			 Log.e("log_tag", "Error parsing dataaaaaa "+e.toString());
			 String bb=getString(R.string.bb);
			 //Toast.makeText(Hoteldatabase.this, "pas de resultas",
						//Toast.LENGTH_LONG).show();
			 AlertDialog alertDialog = new AlertDialog.Builder(Hoteldatabase.this).create();
 
			 alertDialog.setTitle(bb);
 
			 alertDialog.setMessage(bb);
 
			 alertDialog.setButton("OK", new DialogInterface.OnClickListener() {
			      public void onClick(DialogInterface dialog, int which) {
 
			       //here you can add functions
			    	  startActivity(new Intent(
								"com.tunisie.tourisme.Findhotel"));  
 
 
			    } });
 
			 alertDialog.show();
 
 
 
 
		 }       
					final ListView lv = (ListView)findViewById(R.id.list);
 
					final ListAdapter adapter = new SimpleAdapter(Hoteldatabase.this.getBaseContext(),res ,R.layout.main2, 
			                      new String[] {"nom","adresse","ville","img","cat","urlimage","urlgalimage","site","tel","lat","log"}, 
			                       new int[] {R.id.item_title,R.id.item_subtitle,R.id.item_su,R.id.img});
						lv.setAdapter(adapter);
						((SimpleAdapter) adapter).setViewBinder(new MyViewBinder());
 
						((BaseAdapter) lv.getAdapter()).notifyDataSetChanged();
 
 
 
						//lv.setTextFilterEnabled(true);
 
						lv.setOnItemClickListener(new OnItemClickListener() {
							@Override
							public void onItemClick(AdapterView<?> parent, View view,
									int position, long id) {
								@SuppressWarnings("unchecked")
								HashMap<String, String> o = (HashMap<String, String>) lv
										.getItemAtPosition(position);
								Toast.makeText(Hoteldatabase.this, "ID '" + o + "' was clicked.",
										Toast.LENGTH_LONG).show();
								String adresse = o.get("adresse");
								String urlimage = o.get("urlimage");
								String tel = o.get("tel");
								// if (adresse.length() == 0) {
				    					//Toast.makeText(Hoteldatabase.this, "hhhhhhhhhhhhhhhhhg",
				    							//Toast.LENGTH_LONG).show();}
								String cat = o.get("cat");
								String nom = o.get("nom");
								String site = o.get("site");
								String lat = o.get("lat");
								String log = o.get("log");
 
								//Intent nomIntent = new Intent();
 
 
 
								Intent nomIntent = new Intent(Hoteldatabase.this, Info.class);
								nomIntent.putExtra("urlimage", urlimage);
								nomIntent.putExtra("cat", cat);
								nomIntent.putExtra("nom", nom);
								nomIntent.putExtra("lat", lat);
								nomIntent.putExtra("log", log);
								nomIntent.putExtra("tel", tel);
							nomIntent.putExtra("adresse", adresse);
								nomIntent.putExtra("site", site);
 
								//nomIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
								startActivity(nomIntent);
								//nomIntent.setAction("com.tunisie.tourisme.Info");
 
								//nomIntent.addCategory(Intent.CATEGORY_DEFAULT);
 
								//sendBroadcast(nomIntent);
 
								 //startService(nomIntent);
 
							}
 
 
 
 
 
							});
 
						}
 
 
 
 
 
 
 
 
 
 
 
 
}
Menu.java

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
92
93
package com.tunisie.tourisme;
 
 
 
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
 
public class Menu extends Activity  {
 
 
 
	/** Called when the activity is first created. */
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.menu);
 
 
		Button btnhotel = (Button) findViewById(R.id.button1);
		// Button btnfest =(Button)findViewById(R.id.btnfest);
		Button btnexit = (Button) findViewById(R.id.button3);
 
		btnhotel.setOnClickListener(new View.OnClickListener() {
			@Override
			public void onClick(View v) {
				startActivity(new Intent("com.tunisie.tourisme.Findhotel"));
			}
		});
 
		Button btncafe = (Button) findViewById(R.id.cafe);
		// Button btnfest =(Button)findViewById(R.id.btnfest);
 
 
		btncafe.setOnClickListener(new View.OnClickListener() {
			@Override
			public void onClick(View v) {
				startActivity(new Intent("com.tunisie.tourisme.Findcofe"));
			}
		});
 
		Button btnresto = (Button) findViewById(R.id.button2);
 
 
		btnresto.setOnClickListener(new View.OnClickListener() {
			@Override
			public void onClick(View v) {
				startActivity(new Intent("com.tunisie.tourisme.Findresto"));
			}
		});
 
Button btnag = (Button) findViewById(R.id.ag);
 
 
		btnag.setOnClickListener(new View.OnClickListener() {
			@Override
			public void onClick(View v) {
				startActivity(new Intent("com.tunisie.tourisme.Findaglocation"));
			}
		});
 
		btnexit.setOnClickListener(new View.OnClickListener() {
			@Override
			public void onClick(View v) {
				Intent nomIntent = new Intent(Menu.this, Info.class);
 
				startActivity(nomIntent);
 
 
 
 
 
				//finish();
				//System.exit(0);
				//System.runFinalizersOnExit(true);
				//Process.killProcess(Process.myPid());
				//onDestroy();
				//System.runFinalizersOnExit(true);
 
 
				  //System.exit(0);
 
 
 
			}
		});
 
	}
 
 
}




info.java
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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
package com.tunisie.tourisme;
 
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
 
import android.app.Activity;
import android.app.Service;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.net.Uri;
import android.os.Bundle;
import android.os.IBinder;
import android.telephony.PhoneStateListener;
import android.telephony.TelephonyManager;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.RatingBar;
import android.widget.TextView;
 
public class Info extends Activity {
	final Context context = this;
 
	//List<Map<String,Object>> res = new ArrayList<Map<String,Object>>();
 
	Map<String,Object> map = new HashMap<String,Object>();
 
	// String url ;
	public void onCreate ( Bundle savedInstanceState) {
 
 
		super.onCreate(savedInstanceState);
		//Bundle b10 = intent.getExtras();
		//super.onCreate(savedInstanceState);
		setContentView(R.layout.info);
 
		if (this.getIntent().getExtras() != null){
 
			Bundle b10 = this.getIntent().getExtras();
			final String url = b10.getString("urlimage");
 
			//float cat = Float.valueOf(b10.getString("cat"));
 
			map.put("cat",Float.valueOf(b10.getString("cat")));
 
 
			final Float lat = Float.valueOf(b10.getString("lat"));
			final Float log = Float.valueOf(b10.getString("log"));
 
			final String tel = b10.getString("tel");
			// Button btnMap=(Button)findViewById(R.id.btnsite);
			//TextView tvv = (TextView) findViewById(R.id.t5);
 
			final String nom = b10.getString("nom");
			TextView tvv = (TextView) findViewById(R.id.t5);
			final String site = b10.getString("site");
			Button btn2 = (Button) findViewById(R.id.appel);
			tvv.setText(nom);
			PhoneCallListener phoneListener = new PhoneCallListener();
			TelephonyManager telephonyManager = (TelephonyManager) this
				.getSystemService(Context.TELEPHONY_SERVICE);
			telephonyManager.listen(phoneListener,PhoneStateListener.LISTEN_CALL_STATE);
 
 
 
			btn2.setOnClickListener(new View.OnClickListener() {
 
 
 
 
 
 
 
				@Override
				public void onClick(View v) {
					Intent callIntent = new Intent(Intent.ACTION_CALL);
					callIntent.setData(Uri.parse("tel:"+tel));
 
					//callIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
 
 
					startActivity(callIntent);
 
 
				}
			});
 
			Button btnM = (Button) findViewById(R.id.reserver);
			btnM.setOnClickListener(new View.OnClickListener() {
 
				@Override
				public void onClick(View v) {
 
					Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(site));
 
					startActivity(intent);
				}
			});
			Button carte = (Button) findViewById(R.id.button1);
 
			carte.setOnClickListener(new View.OnClickListener() {
 
				@Override
				public void onClick(View v) {
 
					Intent nomIntent = new Intent(Info.this, Mapclass.class);
					nomIntent.putExtra("lat", lat);
					nomIntent.putExtra("log", log);
					startActivity(nomIntent);
				}
			});
 
 
 
 
 
			TextView tv = (TextView) findViewById(R.id.t2);
 
			tv.setText(nom);
			//les etoils des hotels
			RatingBar stars = (RatingBar) findViewById(R.id.ratinggg);
			stars.setNumStars(5);
			stars.setRating((Float) map.get("cat")); // b10 .getString( "a" )
 
Button carte2 = (Button) findViewById(R.id.testimage);
 
			carte2.setOnClickListener(new View.OnClickListener() {
 
				@Override
				public void onClick(View v) {
 
					Intent nomIntent = new Intent(Info.this, Menu.class);
 
					startActivity(nomIntent);
				}
			});
 
 
 
 
 
 
			ImageView image = (ImageView) findViewById(R.id.iii);
 
 
 
 
 
 
			//creation d image
			URL pictureURL = null;
			try {
 
				//Map<String,Object> map = new HashMap<String,Object>();
				pictureURL = new URL(url);
				// map.put("lat",pictureURL);
 
 
			} catch (MalformedURLException e1) {
				// TODO Auto-generated catch block
				e1.printStackTrace();
			}
			Bitmap bitmap = null;
 
			try {
 
 
				bitmap = BitmapFactory.decodeStream(pictureURL.openStream());
 
 
 
 
				image.setImageBitmap(bitmap);
 
			} catch (IOException e1) {
				// TODO Auto-generated catch block
				e1.printStackTrace();
 
 
			}
 
	}
 
 
 
 
 
 
 
	}
 
 
 
 
 
 
	private class PhoneCallListener extends PhoneStateListener {
 
 
		private boolean isPhoneCalling = false;
 
		String LOG_TAG = "LOGGING 123";
 
		@Override
		public void onCallStateChanged(int state, String incomingNumber) {
 
			if (TelephonyManager.CALL_STATE_RINGING == state) {
				// phone ringing
				Log.i(LOG_TAG, "RINGING, number: " + incomingNumber);
			}
 
			if (TelephonyManager.CALL_STATE_OFFHOOK == state) {
				// active
				Log.i(LOG_TAG, "OFFHOOK");
 
				isPhoneCalling = true;
			}
 
			if (TelephonyManager.CALL_STATE_IDLE == state) {
				// run when class initial and phone call ended, 
				// need detect flag from CALL_STATE_OFFHOOK
				Log.i(LOG_TAG, "IDLE");
 
				if (isPhoneCalling) {
 
					Log.i(LOG_TAG, "restart app");
 
					// restart app
					//Intent i = getBaseContext().getPackageManager()
					//	.getLaunchIntentForPackage(
							//getBaseContext().getPackageName());
 
					Intent i = new Intent(Intent.ACTION_CALL);
 
 
					i.setComponent(new ComponentName("com.tunisie.tourisme","com.tunisie.tourisme.Info"));
					i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
 
 
					startActivity(i);
 
					isPhoneCalling = false;
				}
 
			}
		}
	}
 
 
 
}