Voila J'ai une base de donnée MySQL et je veu chercher mes variable suivant la date a travers mon application Android

Voici le Code XML et le Screen :
Code XML : 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
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >
 
    <TextView
        android:id="@+id/textView1"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="Saisie La Date :  ( JJ/MM/AA )"
        android:textAppearance="?android:attr/textAppearanceLarge" android:gravity="center"/>
 
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content" >
 
        <EditText
            android:id="@+id/date123"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:ems="10" />
 
        <Button
            android:id="@+id/button1"
            android:layout_width="138dp"
            android:layout_height="wrap_content"
            android:text="Afficher" />
 
    </LinearLayout>
      <!-- Main ListView 
		 Always give id value as list(@android:id/list)
	-->
    <ListView
        android:id="@android:id/list"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"/>
 
</LinearLayout>



voici le code PHP date.php:

Code PHP : 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
<?php
$Date=$_POST['Date']; 
 $base = mysql_connect ('localhost', 'root', '');  
 mysql_select_db ('trackeur', $base) ;  
$p=0;
$req = mysql_query("select * from clients WHERE username = 'roger'");
while($dnn = mysql_fetch_array($req))
{
$IMEI = $dnn['IMEI'];
 
$req1 = mysql_query("select * from data WHERE IMEI = '$IMEI' AND Date='$Date' ORDER BY id DESC");
 
while($row1 = mysql_fetch_array($req1))
 
{   
     $output1[]=$row1;    
  }
  }
 //on encode en JSON 
 
echo("{\"Date\":");
 print(json_encode($output1));
 echo("}");
 //echo("\n{\"fermer\":");
 //print(json_encode($output2));
 //echo("}");
 mysql_free_result ($req1);  
 $lat = $row1['Latitude']/100;
$lng = $row1['Longitude']/100;
$url = "http://maps.google.com/maps/geo?q=$lat,$lng&amp;output=json&amp;sensor=false";
$data = @file_get_contents($url);          //read the HTTP request
$jsondata = json_decode($data,true);       //parse the JSOPN response
 
?>

le code Java date.java pour envoyer une requête post a date.php
Code JAVA : 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
package com.bibo;
import java.util.ArrayList;
import java.util.HashMap;
 
import org.apache.http.NameValuePair;
import org.apache.http.message.BasicNameValuePair;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
 
import com.chifco.CustomHttpClient;
 
import android.app.Activity;
import android.app.ListActivity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.AdapterView;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ListAdapter;
import android.widget.ListView;
import android.widget.MediaController;
import android.widget.SimpleAdapter;
import android.widget.TextView;
import android.widget.Toast;
import android.widget.VideoView;
import android.widget.AdapterView.OnItemClickListener;
 
public class date extends Activity implements OnClickListener {
 
	//On déclare toutes les variables dont on aura besoin
 
	Button Rechercher;
	// url to make request
 
 
 
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.infomapgeneral);
 
      //On récupère tout les éléments de notre interface graphique grâce aux ID
 
 
        Rechercher = (Button) findViewById(R.id.button1);
 
      //On attribut un écouteur d'évènement à tout les boutons
 
 
        Rechercher.setOnClickListener(new View.OnClickListener() { 
        	public void onClick(View v) {
            // TODO Auto-generated method stub
        		EditText Rdate;
            	Rdate = (EditText)findViewById(R.id.date123);
        		TextView error;
        		error = (TextView)findViewById(R.id.textView1);
        	ArrayList<NameValuePair> postParameters = new ArrayList<NameValuePair>();
        	postParameters.add(new BasicNameValuePair("Date", Rdate.getText().toString()));
 
        	//String valid = "1";
        	String response = null;
        	try {
        	    response = CustomHttpClient.executeHttpPost("http://10.0.2.2/date.php", postParameters);
        	    String res=response.toString();
        	   // res = res.trim();
        	    res= res.replaceAll("\\s+","");         	              	 
        	    //error.setText(res);
 
 
        	} catch (Exception e) {
        		error.setText(e.toString());
        	}
        	 Intent intent = new Intent(getApplicationContext(), datee.class);
       	   startActivity(intent);
 
        }
 
 
 
    });
 
    }
public String geturl(){
	String a="erreur";
	EditText Rdate;
	Rdate = (EditText)findViewById(R.id.date123);
	TextView error;
	error = (TextView)findViewById(R.id.textView1);
ArrayList<NameValuePair> postParameters = new ArrayList<NameValuePair>();
postParameters.add(new BasicNameValuePair("Date", Rdate.getText().toString()));
 
//String valid = "1";
String response = null;
try {
    response = CustomHttpClient.executeHttpPost("http://10.0.2.2/date.php", postParameters);
 
 
    Log.i(a, response);
} catch (Exception e) {
	error.setText(e.toString());
}
return response.toString();
 
 
	}
 
      //voici la méthode qui est exécutée lorsque l'on clique sur un bouton
 
 
 
 
	public void onClick(View arg0) {
		// TODO Auto-generated method stub
 
	}
	public boolean onCreateOptionsMenu(Menu menumain) {
 
        //Création d'un MenuInflater qui va permettre d'instancier un Menu XML en un objet Menu
        MenuInflater inflater = getMenuInflater();
        //Instanciation du menu XML spécifier en un objet Menu
        inflater.inflate(R.layout.menumain, menumain);
 
        //Il n'est pas possible de modifier l'icône d'entête du sous-menu via le fichier XML on le fait donc en JAVA
    	//menumain.getItem(0).getSubMenu().setHeaderIcon(R.drawable.ic_launcher);
 
        return true;
     }
 
       //Méthode qui se déclenchera au clic sur un item
      public boolean onOptionsItemSelected(MenuItem item) {
         //On regarde quel item a été cliqué grâce à son id et on déclenche une action
         switch (item.getItemId()) {
 
            case R.id.optionM2:
            	Intent intent = new Intent(date.this, Forget.class);
         	   startActivity(intent);
                return true;
            case R.id.optionM1:
            	setContentView(R.layout.video);
 
           	 VideoView view = new VideoView(this);
           	 view = (VideoView) findViewById(R.id.videoView1);
                view.setMediaController(new MediaController(this));
                view.setVideoPath("android.resource://"+this.getPackageName()+"/"+R.raw.video22);
                view.requestFocus();
                view.start();
                return true;
           case R.id.quitterM:
               //Pour fermer l'application il suffit de faire finish()
               finish();
               return true;
         }
         return false;}
}

et le code datee.java pour la récupération des donnée dans la listview

Code JAVA : 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
package com.bibo;
 
import java.util.ArrayList;
import java.util.HashMap;
 
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
 
import android.app.ListActivity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ListAdapter;
import android.widget.ListView;
import android.widget.SimpleAdapter;
import android.widget.TextView;
 
public class datee extends ListActivity {
 
	date d=new date();
 
	// url to make request
 
	private static final String url = "http://10.0.2.2/date.php";
	// JSON Node names
	private static final String TAG_Contact = "Date";
	private static final String TAG_IMEI = "IMEI";
	private static final String TAG_id = "id";
	private static final String TAG_Date = "Date";
	private static final String TAG_Latitude = "Latitude";
	private static final String TAG_Heure = "Heure";
	private static final String TAG_Statut = "Statut";
	private static final String TAG_Battery = "Battery";
	private static final String TAG_Longitude = "Longitude";
 
	// contacts JSONArray
	JSONArray contacts = null;
 
 
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.infomaprecherche);
 
		// Hashmap for ListView
		ArrayList<HashMap<String, String>> contactList = new ArrayList<HashMap<String, String>>();
 
		// Creating JSON Parser instance
		JSONParser jParser = new JSONParser();
 
		// getting JSON string from URL
		JSONObject json = jParser.getJSONFromUrl(url);
 
		try {
			// Getting Array of Contacts
			contacts = json.getJSONArray(TAG_Contact);
 
			// looping through All Contacts
			for(int i = 0; i < contacts.length(); i++){
				JSONObject c = contacts.getJSONObject(i);
 
				// Storing each json item in variable
				String id = c.getString(TAG_id);
				String IMEI = c.getString(TAG_IMEI);
				String Date = c.getString(TAG_Date);
				String Latitude = c.getString(TAG_Latitude);
				String Heure = c.getString(TAG_Heure);
				String Longitude = c.getString(TAG_Longitude);
 
 
				// creating new HashMap
				HashMap<String, String> map = new HashMap<String, String>();
 
				// adding each child node to HashMap key => value
				map.put(TAG_id, id);
				map.put(TAG_IMEI, IMEI);
				map.put(TAG_Date, Date);
				map.put(TAG_Longitude, Longitude);
				map.put(TAG_Latitude, Latitude);
				// adding HashList to ArrayList
				contactList.add(map);
			}
		} catch (JSONException e) {
			e.printStackTrace();
		}
 
 
		/**
                 * Updating parsed JSON data into ListView
                 * */
		ListAdapter adapter = new SimpleAdapter(this, contactList,
				R.layout.list_item,
				new String[] { TAG_IMEI, TAG_Date, TAG_Latitude, TAG_Longitude },new int[] {
				R.id.IMEI, R.id.date, R.id.latitude, R.id.longitude });
 
		setListAdapter(adapter);
 
		// selecting single ListView item
		ListView lv = getListView();
 
		// Launching new screen on Selecting Single ListItem
		lv.setOnItemClickListener(new OnItemClickListener() {
 
 
			public void onItemClick(AdapterView<?> parent, View view,int position, long id) {
				// getting values from selected ListItem
				String imei = ((TextView) view.findViewById(R.id.IMEI)).getText().toString();
				String date = ((TextView) view.findViewById(R.id.date)).getText().toString();
				String latitude = ((TextView) view.findViewById(R.id.latitude)).getText().toString();
				String longitude = ((TextView) view.findViewById(R.id.longitude)).getText().toString();
 
				// Starting new intent
				Intent in = new Intent(getApplicationContext(), SingleMenuItem.class);
				in.putExtra(TAG_IMEI, imei);
				in.putExtra(TAG_Date, date);
				in.putExtra(TAG_Latitude, latitude);
				in.putExtra(TAG_Longitude, longitude);
				startActivity(in);
 
			}
		});
 
 
 
	}
 
}

==> s'il vous plais Es ce que je peu rendre les 2 fichier java en un seul fichier ( j'ai essailler mais sa affiche plusieurs erreur ) pour envoyer un Post et récupirer les donnée en méme temps car la sa marche pas et bien sure sa affiche une liste vide
je serai vraiment très reconnaissant a celui qui m'aiderai a résoudre ce problème car j'ai essayer plusieurs méthode durent ces 2 dernier jour et la je suis vraiment bloqué


( Voila Mon essai pour les combiner en un seul fichier qui est plain d'erreur )

Code JAVA : 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
package com.bibo;
import java.util.ArrayList;
import java.util.HashMap;
 
import org.apache.http.NameValuePair;
import org.apache.http.message.BasicNameValuePair;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
 
import com.chifco.CustomHttpClient;
 
import android.app.Activity;
import android.app.ListActivity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.AdapterView;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ListAdapter;
import android.widget.ListView;
import android.widget.MediaController;
import android.widget.SimpleAdapter;
import android.widget.TextView;
import android.widget.Toast;
import android.widget.VideoView;
import android.widget.AdapterView.OnItemClickListener;
 
public class date extends ListActivity implements OnClickListener {
 
	//On déclare toutes les variables dont on aura besoin
 
	Button Rechercher;
	// url to make request
	private static final String TAG_Contact = "Date";
	private static final String TAG_IMEI = "IMEI";
	private static final String TAG_id = "id";
	private static final String TAG_Date = "Date";
	private static final String TAG_Latitude = "Latitude";
	private static final String TAG_Heure = "Heure";
	private static final String TAG_Statut = "Statut";
	private static final String TAG_Battery = "Battery";
	private static final String TAG_Longitude = "Longitude";
 
	// contacts JSONArray
	JSONArray contacts = null;
 
 
 
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.infomapgeneral);
 
      //On récupère tout les éléments de notre interface graphique grâce aux ID
 
 
        Rechercher = (Button) findViewById(R.id.button1);
 
      //On attribut un écouteur d'évènement à tout les boutons
 
 
        Rechercher.setOnClickListener(new View.OnClickListener() { 
        	public void onClick(View v) {
            // TODO Auto-generated method stub
        		EditText Rdate;
            	Rdate = (EditText)findViewById(R.id.date123);
        		TextView error;
        		error = (TextView)findViewById(R.id.textView1);
        	ArrayList<NameValuePair> postParameters = new ArrayList<NameValuePair>();
        	postParameters.add(new BasicNameValuePair("Date", Rdate.getText().toString()));
 
        	//String valid = "1";
        	String response = null;
        	try {
        	    response = CustomHttpClient.executeHttpPost("http://10.0.2.2/date.php", postParameters);
        	    String res=response.toString();
        	   // res = res.trim();
        	    res= res.replaceAll("\\s+","");         	              	 
        	    //error.setText(res);
        		// Hashmap for ListView
        		ArrayList<HashMap<String, String>> contactList = new ArrayList<HashMap<String, String>>();
 
        		// Creating JSON Parser instance
        		JSONParser jParser = new JSONParser();
 
        		// getting JSON string from URL
        		JSONObject json = jParser.getJSONFromUrl("http://10.0.2.2/date.php");
 
        		try {
        			// Getting Array of Contacts
        			contacts = json.getJSONArray(TAG_Contact);
 
        			// looping through All Contacts
        			for(int i = 0; i < contacts.length(); i++){
        				JSONObject c = contacts.getJSONObject(i);
 
        				// Storing each json item in variable
        				String id = c.getString(TAG_id);
        				String IMEI = c.getString(TAG_IMEI);
        				String Date = c.getString(TAG_Date);
        				String Latitude = c.getString(TAG_Latitude);
        				String Heure = c.getString(TAG_Heure);
        				String Longitude = c.getString(TAG_Longitude);
 
 
        				// creating new HashMap
        				HashMap<String, String> map = new HashMap<String, String>();
 
        				// adding each child node to HashMap key => value
        				map.put(TAG_id, id);
        				map.put(TAG_IMEI, IMEI);
        				map.put(TAG_Date, Date);
        				map.put(TAG_Longitude, Longitude);
        				map.put(TAG_Latitude, Latitude);
        				// adding HashList to ArrayList
        				contactList.add(map);
        			}
        		} catch (JSONException e) {
        			e.printStackTrace();
        		}
 
 
        		/**
                         * Updating parsed JSON data into ListView
                         * */
        		ListAdapter adapter = new SimpleAdapter(this, contactList,
        				R.layout.list_item,
        				new String[] { TAG_IMEI, TAG_Date, TAG_Latitude, TAG_Longitude },new int[] {
        				R.id.IMEI, R.id.date, R.id.latitude, R.id.longitude });
 
        		setListAdapter(adapter);
 
        		// selecting single ListView item
        		ListView lv = getListView();
 
        		// Launching new screen on Selecting Single ListItem
        		lv.setOnItemClickListener(new OnItemClickListener() {
 
 
        			public void onItemClick(AdapterView<?> parent, View view,int position, long id) {
        				// getting values from selected ListItem
        				String imei = ((TextView) view.findViewById(R.id.IMEI)).getText().toString();
        				String date = ((TextView) view.findViewById(R.id.date)).getText().toString();
        				String latitude = ((TextView) view.findViewById(R.id.latitude)).getText().toString();
        				String longitude = ((TextView) view.findViewById(R.id.longitude)).getText().toString();
 
        				// Starting new intent
        				Intent in = new Intent(getApplicationContext(), SingleMenuItem.class);
        				in.putExtra(TAG_IMEI, imei);
        				in.putExtra(TAG_Date, date);
        				in.putExtra(TAG_Latitude, latitude);
        				in.putExtra(TAG_Longitude, longitude);
        				startActivity(in);
 
        			}
        		});
 
 
        	} catch (Exception e) {
        		error.setText(e.toString());
        	}
        	 Intent intent = new Intent(getApplicationContext(), datee.class);
       	   startActivity(intent);
 
        }
 
 
 
    });
 
    }
public String geturl(){
	String a="erreur";
	EditText Rdate;
	Rdate = (EditText)findViewById(R.id.date123);
	TextView error;
	error = (TextView)findViewById(R.id.textView1);
ArrayList<NameValuePair> postParameters = new ArrayList<NameValuePair>();
postParameters.add(new BasicNameValuePair("Date", Rdate.getText().toString()));
 
//String valid = "1";
String response = null;
try {
    response = CustomHttpClient.executeHttpPost("http://10.0.2.2/date.php", postParameters);
 
 
    Log.i(a, response);
} catch (Exception e) {
	error.setText(e.toString());
}
return response.toString();
 
 
	}
 
      //voici la méthode qui est exécutée lorsque l'on clique sur un bouton
 
 
 
 
	public void onClick(View arg0) {
		// TODO Auto-generated method stub
 
	}
	public boolean onCreateOptionsMenu(Menu menumain) {
 
        //Création d'un MenuInflater qui va permettre d'instancier un Menu XML en un objet Menu
        MenuInflater inflater = getMenuInflater();
        //Instanciation du menu XML spécifier en un objet Menu
        inflater.inflate(R.layout.menumain, menumain);
 
        //Il n'est pas possible de modifier l'icône d'entête du sous-menu via le fichier XML on le fait donc en JAVA
    	//menumain.getItem(0).getSubMenu().setHeaderIcon(R.drawable.ic_launcher);
 
        return true;
     }
 
       //Méthode qui se déclenchera au clic sur un item
      public boolean onOptionsItemSelected(MenuItem item) {
         //On regarde quel item a été cliqué grâce à son id et on déclenche une action
         switch (item.getItemId()) {
 
            case R.id.optionM2:
            	Intent intent = new Intent(date.this, Forget.class);
         	   startActivity(intent);
                return true;
            case R.id.optionM1:
            	setContentView(R.layout.video);
 
           	 VideoView view = new VideoView(this);
           	 view = (VideoView) findViewById(R.id.videoView1);
                view.setMediaController(new MediaController(this));
                view.setVideoPath("android.resource://"+this.getPackageName()+"/"+R.raw.video22);
                view.requestFocus();
                view.start();
                return true;
           case R.id.quitterM:
               //Pour fermer l'application il suffit de faire finish()
               finish();
               return true;
         }
         return false;}
}