Criar conexão bluetooth android

1 resposta
P

Olá, tudo bem?
Então preciso criar uma conexão bluetooth, igual ao que já vem instalado no celular.
Que pareie com outros celulares ou dispositivos que tenham bluetooth instalado.
Desde já agradeço.

1 Resposta

P

Como não ouve resposta eu me virei e criei está conexão, que ativa somente o bluetooth, mas testei e quando cliquei no botão ativar bluetooth ele deu erro e fechou o app.
Se alguém poder testar agradecerei muito URL para download: http://www.4shared.com/android/SL4CgyOO/Bluetooth.html?

package br.com.android;

import android.app.Activity;
import android.bluetooth.BluetoothAdapter;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;

public class BluetoothActivity extends Activity {
    

	protected static final int REQUEST_ENABLE_BT = 0;

	/** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
          Button btativa = (Button) findViewById(R.id.btativa);
  btativa.setOnClickListener(new View.OnClickListener() {
	  BluetoothAdapter mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
	public void onClick(View v) {
		// TODO Auto-generated method stub
		if (!mBluetoothAdapter.isEnabled()) {
		    Intent enableBtIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);
		    startActivityForResult(enableBtIntent, REQUEST_ENABLE_BT);
		}
		}
	
});
    }
}
Criado 11 de agosto de 2012
Ultima resposta 12 de ago. de 2012
Respostas 1
Participantes 1