当前位置: 首页>>代码示例>>Java>>正文


Java BluetoothClass类代码示例

本文整理汇总了Java中android.bluetooth.BluetoothClass的典型用法代码示例。如果您正苦于以下问题:Java BluetoothClass类的具体用法?Java BluetoothClass怎么用?Java BluetoothClass使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


BluetoothClass类属于android.bluetooth包,在下文中一共展示了BluetoothClass类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getDeviceClassIcon

import android.bluetooth.BluetoothClass; //导入依赖的package包/类
public int getDeviceClassIcon() {
    Log.d("TAG", "Device.getDeviceClass() = " + getDeviceClass());

    final int deviceClass = getDeviceClass();
    final int deviceClassMasked = deviceClass & 0x1F00;

    if (deviceClass == BluetoothClass.Device.AUDIO_VIDEO_HEADPHONES) {
        return R.drawable.headphone;
    } else if (deviceClass == BluetoothClass.Device.AUDIO_VIDEO_MICROPHONE) {
        return R.drawable.microphone;
    } else if (deviceClassMasked == BluetoothClass.Device.Major.COMPUTER) {
        return R.drawable.computer;
    } else if (deviceClassMasked == BluetoothClass.Device.Major.PHONE) {
        return R.drawable.cell_phone;
    } else if (deviceClassMasked == BluetoothClass.Device.Major.HEALTH) {
        return R.drawable.heart;
    } else {
        return R.drawable.bluetooth;
    }
}
 
开发者ID:tiagohm,项目名称:BlueDroid,代码行数:21,代码来源:Device.java

示例2: type

import android.bluetooth.BluetoothClass; //导入依赖的package包/类
public static SubjectFactory<BluetoothClassSubject, BluetoothClass> type() {
  return new SubjectFactory<BluetoothClassSubject, BluetoothClass>() {
    @Override
    public BluetoothClassSubject getSubject(FailureStrategy fs, BluetoothClass that) {
      return new BluetoothClassSubject(fs, that);
    }
  };
}
 
开发者ID:pkware,项目名称:truth-android,代码行数:9,代码来源:BluetoothClassSubject.java

示例3: populateDeviceLists

import android.bluetooth.BluetoothClass; //导入依赖的package包/类
/**
 * Populates the device names and the device addresses with all the suitable
 * bluetooth devices.
 * 
 * @param bluetoothAdapter the bluetooth adapter
 * @param deviceNames list of device names
 * @param deviceAddresses list of device addresses
 */
public static void populateDeviceLists(
    BluetoothAdapter bluetoothAdapter, List<String> deviceNames, List<String> deviceAddresses) {
  // Ensure the bluetooth adapter is not in discovery mode.
  bluetoothAdapter.cancelDiscovery();

  Set<BluetoothDevice> pairedDevices = bluetoothAdapter.getBondedDevices();
  for (BluetoothDevice device : pairedDevices) {
    BluetoothClass bluetoothClass = device.getBluetoothClass();
    if (bluetoothClass != null) {
      // Not really sure what we want, but I know what we don't want.
      switch (bluetoothClass.getMajorDeviceClass()) {
        case BluetoothClass.Device.Major.COMPUTER:
        case BluetoothClass.Device.Major.PHONE:
          break;
        default:
          deviceAddresses.add(device.getAddress());
          deviceNames.add(device.getName());
      }
    }
  }
}
 
开发者ID:Plonk42,项目名称:mytracks,代码行数:30,代码来源:BluetoothDeviceUtils.java

示例4: isHealthWearable

import android.bluetooth.BluetoothClass; //导入依赖的package包/类
public boolean isHealthWearable(BluetoothDevice device) {
    BluetoothClass bluetoothClass = device.getBluetoothClass();
    if (bluetoothClass == null) {
        LOG.warn("unable to determine bluetooth device class of " + device);
        return false;
    }
    if (bluetoothClass.getMajorDeviceClass() == BluetoothClass.Device.Major.WEARABLE
        || bluetoothClass.getMajorDeviceClass() == BluetoothClass.Device.Major.UNCATEGORIZED) {
        int deviceClasses =
                BluetoothClass.Device.HEALTH_BLOOD_PRESSURE
                | BluetoothClass.Device.HEALTH_DATA_DISPLAY
                | BluetoothClass.Device.HEALTH_PULSE_RATE
                | BluetoothClass.Device.HEALTH_WEIGHING
                | BluetoothClass.Device.HEALTH_UNCATEGORIZED
                | BluetoothClass.Device.HEALTH_PULSE_OXIMETER
                | BluetoothClass.Device.HEALTH_GLUCOSE;

        return (bluetoothClass.getDeviceClass() & deviceClasses) != 0;
    }
    return false;
}
 
开发者ID:scifiswapnil,项目名称:gadgetbridge_artikcloud,代码行数:22,代码来源:AbstractDeviceCoordinator.java

示例5: hasScanGun

import android.bluetooth.BluetoothClass; //导入依赖的package包/类
/**
 * 扫描枪是否连接
 * @return
 */
public boolean hasScanGun() {

    if (mBluetoothAdapter == null) {
        return false;
    }

    Set<BluetoothDevice> blueDevices = mBluetoothAdapter.getBondedDevices();

    if (blueDevices == null || blueDevices.size() <= 0) {
        return false;
    }

    for (Iterator<BluetoothDevice> iterator = blueDevices.iterator(); iterator.hasNext(); ) {
        BluetoothDevice bluetoothDevice = iterator.next();

        if (bluetoothDevice.getBluetoothClass().getMajorDeviceClass() == BluetoothClass.Device.Major.PERIPHERAL) {
            mDeviceName = bluetoothDevice.getName();
            return isInputDeviceExist(mDeviceName);
        }

    }

    return false;

}
 
开发者ID:czhzero,项目名称:scangon,代码行数:30,代码来源:ScanGunKeyEventHelper.java

示例6: onReceive

import android.bluetooth.BluetoothClass; //导入依赖的package包/类
@Override
public void onReceive(Context context, Intent intent) {
    String action = intent.getAction();
    
    if (BluetoothDevice.ACTION_FOUND.equals(action)) {
        BluetoothDevice device = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
        if ((device.getBondState() != BluetoothDevice.BOND_BONDED) && (device.getBluetoothClass().getDeviceClass() == BluetoothClass.Device.TOY_ROBOT)) {
            mNewDevicesArrayAdapter.add(device.getName() + "\n" + device.getAddress());
            findViewById(R.id.title_new_devices).setVisibility(View.VISIBLE);
            findViewById(R.id.no_devices).setVisibility(View.GONE);
        }
    } else if (BluetoothAdapter.ACTION_DISCOVERY_FINISHED.equals(action)) {
        setProgressBarIndeterminateVisibility(false);
        setTitle("Select device");
        findViewById(R.id.button_scan).setVisibility(View.VISIBLE);
    }
}
 
开发者ID:jfedor2,项目名称:nxt-remote-control,代码行数:18,代码来源:ChooseDeviceActivity.java

示例7: populateDeviceLists

import android.bluetooth.BluetoothClass; //导入依赖的package包/类
/**
 * Populates the device names and the device addresses with all the suitable
 * bluetooth devices.
 * 
 * @param bluetoothAdapter
 *            the bluetooth adapter
 * @param deviceNames
 *            list of device names
 * @param deviceAddresses
 *            list of device addresses
 */
public static void populateDeviceLists(BluetoothAdapter bluetoothAdapter, List<String> deviceNames,
		List<String> deviceAddresses) {
	// Ensure the bluetooth adapter is not in discovery mode.
	bluetoothAdapter.cancelDiscovery();

	Set<BluetoothDevice> pairedDevices = bluetoothAdapter.getBondedDevices();
	for (BluetoothDevice device : pairedDevices) {
		BluetoothClass bluetoothClass = device.getBluetoothClass();
		if (bluetoothClass != null) {
			// Not really sure what we want, but I know what we don't want.
			switch (bluetoothClass.getMajorDeviceClass()) {
			case BluetoothClass.Device.Major.COMPUTER:
			case BluetoothClass.Device.Major.PHONE:
				break;
			default:
				deviceAddresses.add(device.getAddress());
				deviceNames.add(device.getName());
			}
		}
	}
}
 
开发者ID:scintero,项目名称:moveon,代码行数:33,代码来源:BluetoothDeviceUtils.java

示例8: getBluetoothDevices

import android.bluetooth.BluetoothClass; //导入依赖的package包/类
public static void getBluetoothDevices(){
    BluetoothAdapter mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();

    mBluetoothAdapter.enable();
    btDeviceNames = new ArrayList<String>();
    Set<BluetoothDevice> a= mBluetoothAdapter.getBondedDevices();
    Iterator I=a.iterator();
    BluetoothDevice n=null;
    while(I.hasNext()) {
        n = (BluetoothDevice) I.next();
        BluetoothClass x=n.getBluetoothClass();
        if(x!=null){
            int xc=x.getDeviceClass();
            if((xc==BluetoothClass.Device.AUDIO_VIDEO_CAR_AUDIO)||
                    (xc==BluetoothClass.Device.AUDIO_VIDEO_PORTABLE_AUDIO)||
                    (xc==BluetoothClass.Device.AUDIO_VIDEO_WEARABLE_HEADSET)||
                    (xc==BluetoothClass.Device.AUDIO_VIDEO_LOUDSPEAKER))
            {
                String k = n.getName();
                btDeviceNames.add(k);
            }
        }
    }
}
 
开发者ID:Akhilsudh,项目名称:EasyBluetooth,代码行数:25,代码来源:BTDataPersistence.java

示例9: isContainBTHeadphone

import android.bluetooth.BluetoothClass; //导入依赖的package包/类
private boolean isContainBTHeadphone(BluetoothAdapter mBluetoothAdapter) {
    Set<BluetoothDevice> pairedDevices = mBluetoothAdapter.getBondedDevices();
    // If there are paired devices
    if (pairedDevices.size() > 0) {
        // Loop through paired devices
        for (BluetoothDevice device : pairedDevices) {
            if (device.getBluetoothClass().getDeviceClass() ==
                    BluetoothClass.Device.AUDIO_VIDEO_CAR_AUDIO) {
                return true;
            } else if (device.getBluetoothClass().getDeviceClass() ==
                    BluetoothClass.Device.AUDIO_VIDEO_HANDSFREE) {
                return true;
            } else if (device.getBluetoothClass().getDeviceClass() ==
                    BluetoothClass.Device.AUDIO_VIDEO_HEADPHONES) {
                return true;
            } else if (device.getBluetoothClass().getDeviceClass() ==
                    BluetoothClass.Device.AUDIO_VIDEO_LOUDSPEAKER) {
                return true;
            } else if (device.getBluetoothClass().getDeviceClass() ==
                    BluetoothClass.Device.AUDIO_VIDEO_WEARABLE_HEADSET) {
                return true;
            }
        }
    }
    return false;
}
 
开发者ID:YA-androidapp,项目名称:WearMusicPlayer,代码行数:27,代码来源:MainActivity.java

示例10: resolveMajorDeviceClass

import android.bluetooth.BluetoothClass; //导入依赖的package包/类
public static String resolveMajorDeviceClass(final int majorBtClass) {
    switch (majorBtClass) {
        case BluetoothClass.Device.Major.AUDIO_VIDEO:
            return "Audio/ Video";
        case BluetoothClass.Device.Major.COMPUTER:
            return "Computer";
        case BluetoothClass.Device.Major.HEALTH:
            return "Health";
        case BluetoothClass.Device.Major.IMAGING:
            return "Imaging";
        case BluetoothClass.Device.Major.MISC:
            return "Misc";
        case BluetoothClass.Device.Major.NETWORKING:
            return "Networking";
        case BluetoothClass.Device.Major.PERIPHERAL:
            return "Peripheral";
        case BluetoothClass.Device.Major.PHONE:
            return "Phone";
        case BluetoothClass.Device.Major.TOY:
            return "Toy";
        case BluetoothClass.Device.Major.UNCATEGORIZED:
            return "Uncategorized";
        case BluetoothClass.Device.Major.WEARABLE:
            return "Wearable";
        default:
            return "Unknown (" +majorBtClass+ ")";
    }
}
 
开发者ID:Twelvelines,项目名称:AndroidMuseumBleManager,代码行数:29,代码来源:BluetoothClassResolver.java

示例11: onCreateView

import android.bluetooth.BluetoothClass; //导入依赖的package包/类
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    getDialog().requestWindowFeature(Window.FEATURE_NO_TITLE);

    View view = inflater.inflate(R.layout.view_add_bluetooth_server, container);

    ListView listViewBtPairedPCs = (ListView) view.findViewById(R.id.listViewBtPairedPCs);

    ArrayList<BluetoothDevice> pairedBluetoothList = new ArrayList<>();

    BluetoothAdapter bluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
    Set<BluetoothDevice> pairedDevices = bluetoothAdapter.getBondedDevices();

    if (pairedDevices.size() > 0) {
        for (BluetoothDevice device : pairedDevices) {
            if(device.getBluetoothClass().getMajorDeviceClass() == BluetoothClass.Device.Major.COMPUTER) {
                pairedBluetoothList.add(device);
            }
        }
        if (pairedBluetoothList.size() == 0) {
            Toast.makeText(getActivity().getApplicationContext(), R.string.bluetooth_no_paired_found, Toast.LENGTH_LONG).show();
            return null;
        }
    } else {
        Toast.makeText(getActivity().getApplicationContext(), R.string.bluetooth_no_paired_found, Toast.LENGTH_LONG).show();
        return null;
    }
    BluetoothPairedDevicesAdapter adapter = new BluetoothPairedDevicesAdapter(getActivity(), pairedBluetoothList, this);
    listViewBtPairedPCs.setAdapter(adapter);
    return view;
}
 
开发者ID:rootkiwi,项目名称:an2linuxclient,代码行数:32,代码来源:BluetoothPairedListDialog.java

示例12: onDeviceFound

import android.bluetooth.BluetoothClass; //导入依赖的package包/类
private void onDeviceFound(BluetoothDevice device) {
    if (device != null && device.getName() != null &&
            (device.getBluetoothClass().getDeviceClass() == BluetoothClass.Device.COMPUTER_HANDHELD_PC_PDA ||
            device.getBluetoothClass().getDeviceClass() == BluetoothClass.Device.COMPUTER_PALM_SIZE_PC_PDA ||
            device.getBluetoothClass().getDeviceClass() == BluetoothClass.Device.PHONE_SMART)) {
        subscriber.onNext(new BluetoothPeer(device));
    }
}
 
开发者ID:uhuru-mobile,项目名称:mobile-store,代码行数:9,代码来源:BluetoothFinder.java

示例13: onReceive

import android.bluetooth.BluetoothClass; //导入依赖的package包/类
@Override
public void onReceive(Context context, Intent intent) {
    if (intent == null) return;
    Log.w(TAG, "onReceive");

    synchronized (LOCK) {
        if (getScoChangeIntent().equals(intent.getAction())) {
            int status = intent.getIntExtra(AudioManager.EXTRA_SCO_AUDIO_STATE, AudioManager.SCO_AUDIO_STATE_ERROR);

            if (status == AudioManager.SCO_AUDIO_STATE_CONNECTED) {
                if (Build.VERSION.SDK_INT >= 11 && bluetoothHeadset != null) {
                    List<BluetoothDevice> devices = bluetoothHeadset.getConnectedDevices();

                    for (BluetoothDevice device : devices) {
                        if (bluetoothHeadset.isAudioConnected(device)) {
                            int deviceClass = device.getBluetoothClass().getDeviceClass();

                            if (deviceClass == BluetoothClass.Device.AUDIO_VIDEO_HANDSFREE ||
                                    deviceClass == BluetoothClass.Device.AUDIO_VIDEO_CAR_AUDIO ||
                                    deviceClass == BluetoothClass.Device.AUDIO_VIDEO_WEARABLE_HEADSET)
                            {
                                scoConnection = ScoConnection.CONNECTED;

                                if (wantsConnection) {
                                    AudioManager audioManager = ServiceUtil.getAudioManager(context);
                                    audioManager.setBluetoothScoOn(true);
                                }
                            }
                        }
                    }

                }
            }
        }
    }

    handleBluetoothStateChange();
}
 
开发者ID:XecureIT,项目名称:PeSanKita-android,代码行数:39,代码来源:BluetoothStateManager.java

示例14: canBluetooth

import android.bluetooth.BluetoothClass; //导入依赖的package包/类
public boolean canBluetooth() {
	// Detect if any bluetooth a device is available for call
	if (bluetoothAdapter == null) {
	    // Device does not support Bluetooth
		return false;
	}
	boolean hasConnectedDevice = false;
	//If bluetooth is on
	if(bluetoothAdapter.isEnabled()) {
		
		//We get all bounded bluetooth devices
		// bounded is not enough, should search for connected devices....
		Set<BluetoothDevice> pairedDevices = bluetoothAdapter.getBondedDevices();
		for(BluetoothDevice device : pairedDevices) {
			BluetoothClass bluetoothClass = device.getBluetoothClass();
               if (bluetoothClass != null) {
               	int deviceClass = bluetoothClass.getDeviceClass();
               	if(bluetoothClass.hasService(Service.RENDER) ||
               		deviceClass == Device.AUDIO_VIDEO_WEARABLE_HEADSET ||
               		deviceClass == Device.AUDIO_VIDEO_CAR_AUDIO ||
               		deviceClass == Device.AUDIO_VIDEO_HANDSFREE ) {
                    	//And if any can be used as a audio handset
                    	hasConnectedDevice = true;
                    	break;
               	}
			}
		}
	}
	boolean retVal = hasConnectedDevice && audioManager.isBluetoothScoAvailableOffCall();
	Log.d(THIS_FILE, "Can I do BT ? "+retVal);
	return retVal;
}
 
开发者ID:treasure-lau,项目名称:CSipSimple,代码行数:33,代码来源:BluetoothUtils8.java

示例15: foundDevice

import android.bluetooth.BluetoothClass; //导入依赖的package包/类
public boolean foundDevice (BluetoothDevice device)
{
    boolean resultIsNew = false;

    if (device != null && device.getName() != null &&
            (device.getBluetoothClass().getDeviceClass() == BluetoothClass.Device.COMPUTER_HANDHELD_PC_PDA ||
                    device.getBluetoothClass().getDeviceClass() == BluetoothClass.Device.COMPUTER_PALM_SIZE_PC_PDA ||
                    device.getBluetoothClass().getDeviceClass() == BluetoothClass.Device.PHONE_SMART)) {


        if (mPairedDevicesOnly && device.getBondState() == BluetoothDevice.BOND_NONE)
            return false; //we can only support paired devices


        if (!mFoundDevices.containsKey(device.getAddress())) {
            mFoundDevices.put(device.getAddress(), device);
            resultIsNew = true;

            if (mNearbyListener != null) {
                Neighbor neighbor = new Neighbor(device.getAddress(),device.getName(),Neighbor.TYPE_BLUETOOTH);
                mNearbyListener.foundNeighbor(neighbor);
            }
        }

        if (clientThreads.containsKey(device.getAddress()))
            if (clientThreads.get(device.getAddress()).isAlive())
                return false; //we have a running thread here people!

        log("Found device: " + device.getName() + ":" + device.getAddress());

        ClientThread clientThread = new ClientThread(device, mHandler, mPairedDevicesOnly);
        clientThread.start();

        clientThreads.put(device.getAddress(), clientThread);

    }

    return resultIsNew;
}
 
开发者ID:n8fr8,项目名称:LittleBitLouder,代码行数:40,代码来源:BluetoothReceiver.java


注:本文中的android.bluetooth.BluetoothClass类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。