Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import android.bluetooth.BluetoothAdapter;

import android.content.Context;

public class Main {
    public static void toggleBlueTooth(Context context) {
        BluetoothAdapter adapter = BluetoothAdapter.getDefaultAdapter();
        if (adapter != null) {
            switch (adapter.getState()) {
            case BluetoothAdapter.STATE_OFF:
                adapter.enable();
                break;
            case BluetoothAdapter.STATE_ON:
                adapter.disable();
                break;
            }
        }
    }
}