Android:具有多项活动的BluetoothChat示例

时间:2013-09-13 15:07:55

标签: android bluetooth

我想编辑Android BluetoothChat 示例,以便能够将其与多项活动一起使用。因此,我创建了一个扩展应用程序的类,作为here

的建议
public class cBaseApplication extends Application {

    public static cBaseApplication context;

    private BluetoothChatService mBluetoothConnectedThread;

    // Local Bluetooth adapter
    private static BluetoothAdapter mBluetoothAdapter = null;

    @Override
    public void onCreate() {
        super.onCreate();

        context = this;

        // Get local Bluetooth adapter
        mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
    }

    public BluetoothChatService getBluetoothConnectedThread() {
        return mBluetoothConnectedThread;
    }

    public void setBluetoothConnectedThread(BluetoothChatService mBluetoothConnectedThread) {
        this.mBluetoothConnectedThread = mBluetoothConnectedThread;
    }

    public static BluetoothAdapter getBluetoothAdapter() {
        return mBluetoothAdapter;
    }

}

我遇到的问题是:将所需的代码从原始的BluetoothChat类移动到新的应用程序类。

// Initialize the BluetoothChatService to perform bluetooth connections
        mChatService = new BluetoothChatService(this, mHandler);

0 个答案:

没有答案