Chronogps Posted February 20, 2011 Share Posted February 20, 2011 Soit le code suivant : class BluetoothSocketListener implements Runnable { public BluetoothSocketListener(...) { (...) } public void run() { (...) } } public class MyApp extends Activity implements LocationListener { BluetoothSocketListener bsl = new BluetoothSocketListener(...); Thread MessageListener = new Thread(bsl); MessageListener.start(); (...) public void onLocationChanged(Location loc) { (...) } } Comment depuis la fonction run() appeler la fonction onLocationChanged() ? En clair comment passer l'adresse de cette fonction via l'instanciation de BluetoothSocketListener ? Merci pour vos lumières ! Link to comment Share on other sites More sharing options...
Alocaly Posted February 20, 2011 Share Posted February 20, 2011 Tu ne peux pas passer le this ( ton instance de "MyApp" ) a ton listener ? Emmanuel / Alocaly Link to comment Share on other sites More sharing options...
Chronogps Posted February 20, 2011 Author Share Posted February 20, 2011 Effectivement, ca se compile en tout cas. Je vais voir ce que cela donne à l'exécution. Merci ! Link to comment Share on other sites More sharing options...
moritan Posted February 21, 2011 Share Posted February 21, 2011 Utilise un Handler. Link to comment Share on other sites More sharing options...
Chronogps Posted February 21, 2011 Author Share Posted February 21, 2011 Utilise un Handler. Tu veux dire pour appeler la fonction ? effectivement ce sera mieux sinon plantage garantie dès un accès UI. Link to comment Share on other sites More sharing options...
moritan Posted February 21, 2011 Share Posted February 21, 2011 Comme le dit la doc http://developer.android.com/guide/appendix/faq/commontasks.html#threading Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.