Comment faire pour Envoyer/recevoir des chaîne de caractères via bluetooth android à un autre téléphone android

Dans mon application android je veux envoyer la chaîne à partir d'un appareil à l'autre via Bluetooth.
Les appareils disponibles sont affichées dans la liste.... Je veux envoyer la chaîne avec de jumelage ... j'm pas réussi à établir la connexion entre les appareils... quelqu'un Peut m'aider pour établir la connexion et pour envoyer la chaîne...j'ai beaucoup d'exemples, mais ne peux pas comprendre à quel stuff nécessaire pour le transfert de fichiers. si quelqu'un le faire déjà pls m'aider. Inachevés code est donné ci-dessous

public class MainActivity extends Activity 
{
ToggleButton tb1;
Button tb2, tb3;
String tbstate1, tbstate2, tbstate3;
EditText textPhoneNo, textTo;
BluetoothAdapter myBTadapter;
ArrayAdapter<String> btArrayAdapter;
String tbstate;
ListView listDevicesFound;
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
tb1 = (ToggleButton) findViewById(R.id.m_m_btn);
tb2 = (Button) findViewById(R.id.sms_btn);
tb3 = (Button) findViewById(R.id.email_btn);
myBTadapter = BluetoothAdapter.getDefaultAdapter();
listDevicesFound = (ListView) findViewById(R.id.devicesfound);
btArrayAdapter = new ArrayAdapter<String>(MainActivity.this,android.R.layout.simple_list_item_1);
listDevicesFound.setAdapter(btArrayAdapter);
//     listDevicesFound.setAdapter(detectedAdapter);
//     listDevicesFound = new ListItemClicked();
//      detectedAdapter.notifyDataSetChanged();
//     
registerReceiver(ActionFoundReceiver, new IntentFilter(BluetoothDevice.ACTION_FOUND));
tb1.setOnClickListener(new OnClickListener()
{
@Override
public void onClick(View v)
{
tbstate = tb1.getText().toString();
if (tbstate.equals("ON"))
{
if (myBTadapter == null) 
{
tb1.setEnabled(false);
}
else
{
if (myBTadapter.isEnabled())
{
myBTadapter.startDiscovery();
// Toast.makeText(getApplicationContext(), "Bluetooth 1 ",Toast.LENGTH_LONG).show();
//myBTadapter.disable();
}
else 
{
myBTadapter.enable();
myBTadapter.startDiscovery();
//Toast.makeText(getApplicationContext(), "Bluetooth 2 ",Toast.LENGTH_LONG).show();
}
}
//check the status and set the button text
//accordingly
}
else
{
myBTadapter.disable();
btArrayAdapter.clear();
/*if (myBTadapter.isEnabled())
{
myBTadapter.disable();
}
else 
{
Toast.makeText(getApplicationContext(), "Bluetooth 3 ",Toast.LENGTH_LONG).show();
}   */
} 
}
}
);
}
private final BroadcastReceiver ActionFoundReceiver = new BroadcastReceiver() 
{
@Override
public void onReceive(Context context, Intent intent) 
{
//TODO Auto-generated method stub
String action = intent.getAction();
if (BluetoothDevice.ACTION_FOUND.equals(action))
{
BluetoothDevice device = intent .getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
btArrayAdapter.add(device.getName() + "\n"+ device.getAddress());
btArrayAdapter.notifyDataSetChanged();
}
}
};
}

OriginalL'auteur Amith | 2013-06-06