Android Chinese API (65) -- javasthclass [Bluetooth]

Source: Internet
Author: User

 

Preface

This chapter is about android. bluetooth. javasthclass, which is a part of Android bluetooth. It is used to describe the type, characteristics, and other information of a remote device. The getthclass () method is used to obtain the thclass object that represents the property of the remote device. Android 2.3 r1, translated from Sun Yat-sen University's "Android Club SYSU", welcome to visit their WIKI: http://www.android-wiki.net, thanks again "Android Club SYSU "! I look forward to your participation in Android Chinese API translation, contact me over140@gmail.com.

 

Statement

You are welcome to repost, but please keep the original source of the article :)

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

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

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

 

Body

I. Structure

Public final class extends thclass extends Object implements Parcelable

Java. lang. Object

Android. bluetooth. javasthclass

 

Ii. Overview

Represents a Bluetooth class that describes general features and functions of a device. For example, a Bluetooth type specifies a general device type such as a phone, computer, or headset, and can provide services such as audio or phone.

Each Bluetooth category contains 0 or more services and one device category. The device category is divided into major and small device categories.

    BluetoothClassUsed as a clue that can roughly describe a device (such as a device that closes an icon on the user interface), but when the Bluetooth service is actually supported by a device, the introduction of BluetoothClass is less trustworthy. Precise service search is completed through SDP requests. When usedcreateRfcommSocketToServiceRecord(UUID)AndlistenUsingRfcommWithServiceRecord(String, UUID)When you create an RFCOMM port, the SDP request is automatically executed.

UsegetBluetoothClass()Method to obtain the class provided by the remote device.

 

Iii. Internal class

Class implements thclass. Device

Define constants for all device classes

 

Class implements thclass. Service

Define constants for all service classes

 

 

Iv. Public Methods

Public intDescribeContents()

Describes the types of all special objects contained in the encapsulated group representation.

Return Value

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

Public booleanEquals(Object o)

Compare constants with specific targets. If they are equal, they are marked. To ensure their equality, o must represent the same object, which serves as a constant for comparing class dependencies. It is usually agreed that the comparison should be portable and flexible.

True is returned only when o is an exact same object as the receiver (using the = Operator for comparison. Subclass usually implements the equals (Object) method, so that it will pay attention to the type and status of these two objects.

Generally, for equals (Object) and hashCode () methods, if equals returns true values for any two objects, hashCode () must return the same paper for these objects. This means that the subclass of the Object usually overwrites or does not overwrite the two methods.

Parameters

O objects that need to compare Constants

Return Value

If the specified object is the same as the object, true is returned; otherwise, false is returned.

 

Public intGetDeviceClass()

ReturnBluetoothClassThe device category in (major and minor)

The value returned from the function can beBluetoothClass.DeviceTo determine which device class is encoded in the Bluetooth class.

Return Value

Equipment

 

Public intGetMajorDeviceClass()

ReturnBluetoothClassMain part of the device category in

The value returned from the function can beBluetoothClass.Device.MajorTo determine which main class is encoded in the Bluetooth class.

Return Value

Main Equipment

 

Public booleanHasService(Int service)

If the specified service class isBluetoothClassIf yes, true is returned.

InBluetoothClass.ServiceThe valid service class is a public constant, suchAUDIOClass.

Parameters

Service Legal service

Return Value

Returns true if the service class is supported.

 

Public intHashCode()

Returns the integer Hash code of this object. As agreed, any twoequals(Object)Objects that return true must return the same hash code. This means that the subclass of an object usually overwrites or does not overwrite the two methods.

Note: unless the same comparison information changes, the hash code does not change with time.

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

Return Value

Hash code of the object

 

Public StringToString()

Returns the string of this object, which contains a precise and readable description. The system encourages subclass to override this method, and provides implementation methods that can pay attention to the object type and data. The default implementation method is simply to connect the class name, "@" symbol, and the hexadecimal number of the hashCode () method of the object (as shown in the following expression ):

  

If you want to implement your own toString method, see Writing a usefultoStringMethod.

Return Value

A printable string in this object.

 

Public voidWriteToParcel(Parcel out, int flags)

Write the data of the class to the external provided Parcel.

Parameters

Parcel to be written to the out object

How flags and objects need to be written with additional flags. It may be 0, or it may bePARCELABLE_WRITE_RETURN_VALUE.

 

End

This article on Android Bluetooth has been reposted. I have reviewed it and added a few missing parts. Thank you again!

 

 

Related Article

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.