mardi 4 août 2015

Passing data between activities andoid

I have app with two activities. The first one (Bluetooth Activity) is to search for Bluetooth devices and connect with them (Working fine). The second (Control Activity) have a control buttons. Each button suppose to send command via Bluetooth.

The problem is: 1. When I use Intent it pass date from "Control Activity" to "Bluetooth Activity", but also change the view to "Bluetooth Activity" which I don't want.

2.I have multiple command in "Control Activity", if I use "intent.putExtra" it's need to insert a KEY. How to find which key is sent.

"Control Activity"

Intent intent = new Intent(this,Bluetooth.class);
    intent.putExtra("blue", "b");
    startActivity(intent);

"Bluetooth Activity"

getIntent().getExtras().getString("blue")

Aucun commentaire:

Enregistrer un commentaire