Android Chinese API (+)--bluetoothclass[Bluetooth]

Source: Internet
Author: User

Objective

This chapter is android.bluetooth.BluetoothClass for the translation of the sections of the Android Bluetooth section. Used to describe the type, characteristics, and other information of the remote device, and obtain the Bluetoothclass object representing the properties of the remote device through the Getbluetoothclass () method. Version for Android 2.3 R1, translated from Zhongshan University's "Android Club Sysu", welcome to visit their wiki:http://www.android-wiki.net, thanks again for "Android Club Sysu"! Look forward to your participation in the translation of the Android Chinese API, contact me [email protected].

Statement

Welcome reprint, but please keep the original source of the article:)

Android Club sysu:http://www.android-wiki.net

Blog Park: http://www.cnblogs.com/

Android Chinese translation group: http://code.taobao.org/project/view/404/

Body

First, the structure

Public final class Bluetoothclass extends Object implements parcelable

Java.lang.Object

Android.bluetooth.BluetoothClass

Ii. Overview

  Represents a Bluetooth class that describes the common features and functions of a device. For example, a Bluetooth class would designate a generic device type, such as a phone, computer, or headset, to provide services such as audio or telephone.

  Each Bluetooth class is comprised of 0 or more service classes, as well as a device class. The device class will be decomposed into major and minor device class parts.

    BluetoothClassused as a clue to roughly describe a device (such as a device that turns off the icon on the user interface), but when the Bluetooth service is in fact supported by a device, Bluetoothclass's introduction is less reliable. The exact service search is done through the SDP request. When createRfcommSocketToServiceRecord(UUID) listenUsingRfcommWithServiceRecord(String, UUID) The Rfcomm port is used and created, the SDP request is executed automatically.

Use getBluetoothClass() method to obtain the classes that are provided for the remote device.

Iii. Internal class

class Bluetoothclass.device

  Define constants for all device classes

  Class Bluetoothclass.service

  Define constants for all service classes

Iv. Public methods

public int describecontents ()

Describes the kinds of all special objects that are contained in the representation of a encapsulated group.

return value

A bitmask that indicates the collection of special object types that are arranged by the Parcelabel.

Public boolean equals (Object o)

compare constants with specific targets. If they are equal, mark them out. To guarantee equality, o must represent the same object as the constant that uses the class dependency comparison. It is generally agreed that the comparison is both portable and flexible.

The implementation of this object returns a true value only if and only if O is the exact same object as the receiver (which is compared using the = = operator). Subclasses typically implement the Equals (object) method so that it takes care of the type and state of both objects.

As a general rule, for the Equals (Object) and Hashcode () methods, if equals returns true for any two objects, then hashcode () must return the same paper for those objects. This means that the subclass of the object is usually overwritten, or both methods are not overwritten.

Parameters

O objects that need to compare constants

return value

Returns true if the specified object and the object are equal, otherwise false.

public int Getdeviceclass ()

Returns BluetoothClass the part of the device class (primary and small) in

The value returned from the function can be compared with the BluetoothClass.Device public constants in, which determines which device class is encoded in the Bluetooth class.

return value

Device class Section

public int getmajordeviceclass ()

return BluetoothClass the main part of the device class in

The value returned from the function can be compared with the BluetoothClass.Device.Major public constant in, which determines which primary class is encoded in the Bluetooth class.

return value

Main Equipment Class Section

Public Boolean hasservice (int service)

If the specified service class is BluetoothClass is supported, returns True

In BluetoothClass.Service , a legitimate service class is a public constant, such as a AUDIO class.

Parameters

Service Legal Services class

return value

Returns true if the service class can be supported

public int hashcode ()

returns the integer hash code for this object. By convention, any two equals(Object) objects that return true in the must return the same hash code. This means that the subclass of the object usually overrides or does not overwrite both methods.

Note: unless the same contrast information changes, the hash code does not change over time.

If you want to implement your own hash code method, see Writing a correct hashCode .

return value

The hash code of the object

Public String toString ()

Returns a string of this object that contains an accurate and readable description. Subclasses are encouraged to rewrite the method and provide a way to implement the object's type and data. The default implementation method simply joins the class name, the "@" symbol, and the 16-digit number of the object's Hashcode () method (the expression shown below):

  

if you want to implement your own toString methods, see Writing a useful toString method.

return value

A string in the object that can be printed.

Public void writetoparcel (Parcel out, int flags)

writes the data of the class to an externally supplied parcel

Parameters

parcel the Out object needs to be written

Flags and how the object needs to be written about the additional flags. It could be 0, or it could be PARCELABLE_WRITE_RETURN_VALUE .

End

About Android Bluetooth This article has been reproduced, here do a tidy and simple review, supplemented by a few missing parts, thank them again!

Android Chinese API (+)--bluetoothclass[Bluetooth]

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.