Download Documento PDF
Transcript
3.
SVILUPPO
attraverso la funzione startActivityForResult che stabilisce anche il messaggio di
risposta una volta terminata la sua esecuzione.
public void onItemClick(AdapterView<?> parent,
View view, int position, long id) {
Intent myIntent = new Intent(view.getContext(), MoteParam.class);
int index = ((Mote)mConversationView
.getItemAtPosition(position)).getNodeId();
myIntent.putExtra("mote_id",Integer.toString(index));
myIntent.putExtra("mote_tx_pow",
Integer.toString(mote[index].getTxPow()));
myIntent.putExtra("mote_rssi",
Integer.toString(mote[index].getRssi()));
myIntent.putExtra("mote_lqi",
Integer.toString(mote[index].getLqi()));
myIntent.putExtra("mote_pos_x",
Integer.toString(mote[index].getX()));
myIntent.putExtra("mote_pos_y",
Integer.toString(mote[index].getY()));
startActivityForResult(myIntent, REQUEST_POSITION_MOTE);
...
Una volta stabilita la posizione del nodo fisso premendo il pulsante per l’invio
del messaggio l’activity corrente crea un nuovo oggetto Intent con i dati da inviare
l’activity chiamante, ovvero quella principale, e a questo punto termina la sua
esecuzione.
public void onClick(View v) {
// Send a message using content of the edit text widget
TextView pos_x = (TextView) findViewById(R.id.mote_pos_x);
TextView pos_y = (TextView) findViewById(R.id.mote_pos_y);
//send the position
Intent intent = new Intent();
intent.putExtra(EXTRA_SEND_POS_X,pos_x.getText().toString().trim());
50