Voila, dans l'appli que je développe en ce moment, je dois afficher une interface suite à une identification. Je gère bien la communication Client/Serveur lors de l'appui sur le bouton envoyant l'identification au serveur afin de vérifier si celle-ci est correcte.
Le problème est que l'affichage ne se fait pas et cela me dit :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
java.lang.IllegalMonitorStateException: object not locked by thread before notify()
Alors voici le code de mon activité concernant la fenêtre d'identification

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
public class IdentificationActivity extends Activity implements OnClickListener {
	Button buttonValider = null;
	EditText editNom;
	EditText editPass;
	private String nom;
	private String pass;
	private String reponseConnection;
	private boolean reponseLue = false;
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.identification);
 
 
		editNom = (EditText)findViewById(R.id.editTextNom);
		editPass = (EditText)findViewById(R.id.editTextPass);
		buttonValider = (Button)findViewById(R.id.buttonValidIdent);
		buttonValider.setOnClickListener(this);
 
	}
	@Override
	public void onClick(View v) {	// click sur le bouton valider de l'ihm de creation
		// TODO Auto-generated method stub
 
		if(v == buttonValider) {
			nom = editNom.getText().toString();
			pass = editPass.getText().toString();
			ClientThread Client = new ClientThread(this);
			Client.setNom(nom);
			Client.setPass(pass);
			Thread cThread = new Thread(Client);
			cThread.start();
			while(reponseLue == false) {
				synchronized(this) {
				try {
					wait();
				}
				catch(InterruptedException ie) {
					ie.printStackTrace();
				}
				}
			}
			notify();
			if(reponseConnection.equals("OK")) {
				Intent monIntent = new Intent(this, ConfigurationActivity.class);
				startActivity(monIntent);
			}
		}
 
	}
	public void setReponseConnection(String reponseConnection) {
		this.reponseConnection = reponseConnection;
	}
	public void setReponseLue(boolean reponseLue) {
		this.reponseLue = reponseLue;
	}
 
 
}
Et voici le code de ma classe Thread dans laquelle je redéfinis la méthode run()

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
public class ClientThread implements Runnable {
	private boolean connected;
	private Object ThreadAppelant; 
	private String nom;
	private String pass;
 
	public void setNom(String nom) {
		this.nom = nom;
	}
 
	public void setPass(String pass) {
		this.pass = pass;
	}
 
	public ClientThread(Object threadAppelant) {
		super();
		ThreadAppelant = threadAppelant;
	}
 
	@Override
	public void run() {
		// TODO Auto-generated method stub
		try {
			Log.d("IdentificationActivity", "C: Connecting...");
			Socket socket = new Socket("192.168.58.22", 1234);
			connected = true;
			if(connected) {
				try {
					Log.d("IdentificationAcitivity", "C: Sending Command");
					PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(socket.getOutputStream())), true);
					BufferedReader rd = new BufferedReader(new InputStreamReader(socket.getInputStream()));
					out.println("IDENT,"+nom+","+pass);
					out.flush();
					Log.d("IdentificationActivity", "C: Sent");
					if(ThreadAppelant instanceof IdentificationActivity)
					{
						IdentificationActivity ident = (IdentificationActivity)ThreadAppelant;
						ident.setReponseConnection(rd.readLine());
						ident.setReponseLue(true);
						ident.notify();
					}
				}
				catch(Exception e) {
					Log.e("IdentificationActivity", "S: Error", e);
				}
			}
			socket.close();
			Log.d("IdentificationAcitivty", "C: Closed");
		}
		catch(Exception e) {
			Log.e("IdentificationActivity", "C: Error", e);
			connected = false;
		}
 
	}
 
}