我在活动主页中有蓝牙连接。我可以在第二次活动中使用此连接吗?
当我启动程序时,我正在显示带有蓝牙连接的表格。连接到蓝牙后,我然后显示主要活动,我可以发送数据,但我想创建第二个活动并发送数据。有可能吗?
package com.led.led;
import android.support.v7.app.ActionBarActivity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.bluetooth.BluetoothSocket;
import android.content.Intent;
import android.view.View;
import android.widget.Button;
import android.widget.SeekBar;
import android.widget.Toast;
import android.app.ProgressDialog;
import android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothDevice;
import android.os.AsyncTask;
import java.io.IOException;
import java.util.UUID;
public class ledControl extends ActionBarActivity {
Button btnROn,btnGOn,btnBOn,btnRGOn,btnRBOn,btnGBOn,btnRGBOn,btnWOn,btnOffAll,btnWOff;
Button btnS0,btnS1,btnS2,btnL0,btnL1,btnL2, btnOpenScrollBar;
SeekBar brightnessR,brightnessG,brightnessB,brightnessW;
String address = "0123";
byte[] BTData2 = new byte[2];
byte[] BTData4 = new byte[4];
byte[] BTData6 = new byte[6];
byte[] BTData8 = new byte[8];
private ProgressDialog progress;
BluetoothAdapter myBluetooth = null;
BluetoothSocket btSocket = null;
private boolean isBtConnected = false;
//SPP UUID. Look for it
static final UUID myUUID = UUID.fromString("00001101-0000-1000-8000-00805F9B34FB");
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
Intent newint = getIntent();
address = newint.getStringExtra(DeviceList.EXTRA_ADDRESS); //receive the address of the bluetooth device
setContentView(R.layout.activity_led_control);
brightnessB = (SeekBar)findViewById(R.id.seekBarB);
brightnessW = (SeekBar)findViewById(R.id.seekBarW);
new ConnectBT().execute(); //Call the class to connec