亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? bluetoothdiscovery.java

?? 藍牙手機通信示例代碼
?? JAVA
?? 第 1 頁 / 共 3 頁
字號:
// Copyright 2004 Nokia Corporation.
//
// THIS SOURCE CODE IS PROVIDED 'AS IS', WITH NO WARRANTIES WHATSOEVER,
// EXPRESS OR IMPLIED, INCLUDING ANY WARRANTY OF MERCHANTABILITY, FITNESS
// FOR ANY PARTICULAR PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE
// OR TRADE PRACTICE, RELATING TO THE SOURCE CODE OR ANY WARRANTY OTHERWISE
// ARISING OUT OF ANY PROPOSAL, SPECIFICATION, OR SAMPLE AND WITH NO
// OBLIGATION OF NOKIA TO PROVIDE THE LICENSEE WITH ANY MAINTENANCE OR
// SUPPORT. FURTHERMORE, NOKIA MAKES NO WARRANTY THAT EXERCISE OF THE
// RIGHTS GRANTED HEREUNDER DOES NOT INFRINGE OR MAY NOT CAUSE INFRINGEMENT
// OF ANY PATENT OR OTHER INTELLECTUAL PROPERTY RIGHTS OWNED OR CONTROLLED
// BY THIRD PARTIES
//
// Furthermore, information provided in this source code is preliminary,
// and may be changed substantially prior to final release. Nokia Corporation
// retains the right to make changes to this source code at
// any time, without notice. This source code is provided for informational
// purposes only.
//
// Nokia and Nokia Connecting People are registered trademarks of Nokia
// Corporation.
// Java and all Java-based marks are trademarks or registered trademarks of
// Sun Microsystems, Inc.
// Other product and company names mentioned herein may be trademarks or
// trade names of their respective owners.
//
// A non-exclusive, non-transferable, worldwide, limited license is hereby
// granted to the Licensee to download, print, reproduce and modify the
// source code. The licensee has the right to market, sell, distribute and
// make available the source code in original or modified form only when
// incorporated into the programs developed by the Licensee. No other
// license, express or implied, by estoppel or otherwise, to any other
// intellectual property rights is granted herein.


//==============================================================================
// Package Statements



//==============================================================================
// Import Statements

import javax.microedition.lcdui.*;
import javax.microedition.io.*;
import java.io.*;
import java.util.Vector;
import javax.bluetooth.*;
import java.util.Timer;
import java.util.TimerTask;


//==============================================================================
// CLASS (OR INTERFACE) DECLARATIONS

/** The <code>BluetoothDiscovery</code> provides an easy API to search devices
 * and services.<br>
 * Main methods to use are searchService and waitOnConnection.<br>
 * searchService is used to search the vicinity for other BluetoothDevices and
 * connect to them if the offered service matches.<br>
 * waitOnConnection is used to offer an service and wait on other devices to
 * connect to the local device.<br>
 * Before these methods are called you usually should setup the name and the service.
 * This is done with setName and setServiceUUID.<br>
 * Please note that for discoverability mode and for inquiry the LIAC is used, so
 * that you will find only devices which are in limited inquiry access mode. This
 * is because this Java code is optimized for MIDlet to MIDlet communication, so that
 * the same MIDlet is running on local and on remote device. With using LIAC the
 * search process is much faster in environments with many Bluetooth devices around.<br>
 */

public class BluetoothDiscovery
    extends Alert
implements CommandListener
{
    //==============================================================================
    // Final variables (Class constants)
    /** The CONCEPT_SDK_BUILD constant determines if MIDlet should run in Concept SDK emulator.
     * Unfortunately there are a few flaws in the emulator, so that certain functionality
     * cannot be used. If you want to debug in the Concept SDK emulator on PC please set the constant
     * to true, for the final target (phone) release you should set this to false.
     * Also, if CONCEPT_SDK_BUILD is true, a short Alert is shown (in setServiceUUID, which is one of
     * the first methods invoked) to make you aware that this is not the final build. <br>
     * <img src="doc-files/crop_concept_sdk_build.jpg"><br>
     * The Alert is not shown if CONCEPT_SDK_BUILD is false.
     */
    static public final boolean CONCEPT_SDK_BUILD = false;   // It's public so that it's description is shown in javadoc
    // Attribute ID for service name for base language
    static private final int SERVICE_NAME_BASE_LANGUAGE = 0x0100;
    // The major device class (in CoD) used for phones:
    static private final int MAJOR_DEVICE_CLASS_PHONE = 0x0200;
    // Search types
    /** Searches each device for the service. If a device with the service is found
     * the search is cancelled. A connection is setup to that device/service.
     * No device is shown to the user. */
    static public final int SEARCH_CONNECT_FIRST_FOUND = 1;
    /**  Searches each device for the service. All devices with the searched service
     *   will be connected. No devices are shown to the user. */
    static public final int SEARCH_CONNECT_ALL_FOUND = 2;
    /**   Searches for the service on every found device. A list of devices that
     *   offer the service is displayed to the user. User can stop the service
     *   search if at least one device has been found. After stop or after all
     *   devices are shown to the user the user can select one device. This
     *   device is connected. */
    static public final int SEARCH_ALL_DEVICES_SELECT_ONE = 3;
    /**   Searches for the service on every found device. A list of devices that
     *   offer the service is displayed to the user. User can stop the service
     *   search if at least one device has been found. After stop or after all
     *   devices are shown to the user the user can select one or several devices. These
     *   devices are connected.
     *   Note that this functionality is only available on devices which support
     *   point-to-multipoint connectivity (bluetooth.connected.devices.max > 1). If the
     *   device supports only point-to-point connectivity (bluetooth.connected.devices.max = 1) the behaviour is the same as
     *   if  SEARCH_ALL_DEVICES_SELECT_ONE would have been used.
     */
    static public final int SEARCH_ALL_DEVICES_SELECT_SEVERAL = 4;
    /** Maximum number of connectable, active devices  according to Bluetooth specification) */
    static private final int BLUETOOTH_MAX_DEVICES = 7;

    //==============================================================================
    // Class (static) variables

    //==============================================================================
    // Instance variables
    private Display display;  // The used display

    // Bluetooth/JSR82 variables
    private LocalDevice localDevice = null; // Reference to LocalDevice
    private int previousDiscoverabilityMode = -1; // Used to restore discoverabilty mode afterwards
    // UUID:
    // x = random, b = BD address of one of my Bluetooth devices (because BD addresses are also unique)
    // xxxx xxxx xxxx 1xxx 8xxx bbbbbbbbbbbb
    // Eg. for my device = 006057028C19, ie. "00000000000010008000006057028C19"
    private String serviceUUID = null;
    // The name of the device/service
    private String localName = null;

    // Used for Client
    private DiscoveryAgent discoveryAgent; // Reference to DiscoveryAgent (used for Inquiry)
    private Listener listener; // Discovery Listener (used for inquiry)
    private int searchType;    // Holds the search type the user wants to use
    private int serviceSearchTransId; // trans action id for current service search, if there is no serv search this is -1
    private Vector urlStrings; // This holds the url strings of the returned services
    private Vector foundServiceRecords; // holds all the found service records
    private int maxDevices; // Number of max. connectable devices (retrieved by getproperty)
    private DeviceList deviceList;  // List with devices that is shown to the user.
    private String warning; // Warnign presented to the user in case no device or no service was found

    // Used for Server
    private StreamConnectionNotifier notifier;  // For the server
    // Used for both
    private BluetoothConnection[] btConnections;  // All Bluetooth connections

    // Will get value of this, so this can be easily accessed from inner classes
    private BluetoothDiscovery  root;

    // Pointer to the progress bar object (used not only for inquiry)
    private InqProgressBar progressBar;

    // Used for waiting/notify
    private Object block_c;	// for Client
    private Object block_s;	// for Server
    private Object block_ss;	// for termination of service search
    private Object block_notifier;   // For Notifier.close

    //==============================================================================
    // Constructors and miscellaneous (finalize method, initialization block,...)

    /** Creates an <code>BluetoothDiscovery</code> object.
     * @param disp The display object of the MIDlet. Could have been
     * obtained by the MIDlet eg. by calling Display.getDisplay( this ).
     *
     */
    public BluetoothDiscovery( Display disp )
    {
        super( "" );
        // store 'this'
        root = this;
        // store display
        display = disp;
        // Initialize
        progressBar = null;
        deviceList = null;
        // Create object used to synchronize/lock
        block_c = new Object();
        block_s = new Object();
        block_ss = new Object();
        block_notifier = new Object();

        try
        {  // Obtain local device object
            localDevice = LocalDevice.getLocalDevice();
            // Retrieve number of connectable devices
            maxDevices = Integer.parseInt( localDevice.getProperty( "bluetooth.connected.devices.max" ) );
            // Because of definition with parked devices
            if( maxDevices > BLUETOOTH_MAX_DEVICES )
            {   // limit to 7
                maxDevices = BLUETOOTH_MAX_DEVICES;
            }
        }
        catch(Exception e)
        {   // not much that can be done
            localDevice = null;

            String message = "Error trying to get local device properties: " +
                             e.getMessage();
            ErrorScreen.showError(message, display.getCurrent());
        }

    }   /*  End of the constructor method   */

    /** Closes the Notifier.
     * If Notifier is not null, Notifier.close is called . Afterwards
     * Notifier is set to null.
     */
    private void closeNotifier()
    {
        synchronized( block_notifier )
        {
            if( notifier != null )
            {
                try
                {
                    if( ! CONCEPT_SDK_BUILD )
                    {   // Does not work correctly in Concept SDK,
                        // but should be done in real phone to deregister service
                        notifier.close();
                    }
                }
                catch(Exception e)
                {
                    String message = "Error trying to close notifier" +
                                     e.getMessage();
                    ErrorScreen.showError(message, display.getCurrent());
                }
                notifier = null;
            }
        }
    }

    /**
     * Respond to commands.
     * @param c The command.
     * @param s The displayable object. */
    public void commandAction(Command c, Displayable s)
    {
        switch( c.getCommandType() )
        {
            case Command.CANCEL:
                // User chose to cancel this class
                try
                {
                    // Cancel discovery process
                    if( listener != null )
                    {   // cancel client
                        // Info note to user
                        Alert a = new Alert( "", "Search cancelled", null, AlertType.INFO );
                        a.setTimeout( 10000 );  // display max. 10 secs
                        display.setCurrent( a );
                        // cancel Inquiry
                        discoveryAgent.cancelInquiry( listener );
                        // Cancel service search
                        // Because this has to wait on termination a new thread is required.
                        // Otherwise the alert above would not be displayed.
                        waitOnServSearchTermination w = new waitOnServSearchTermination();
                        w.start();
                    }
                    // Remove listener
                    listener = null;
                    // This is used to cancel a server session
                    closeNotifier();
                    // Stop progress bar (if existing)
                    if( progressBar != null )
                    {
                        progressBar.stop();
                        progressBar = null;
                    }
                }
                catch(Exception e)
                {
                    String message = "Error trying to cancel: " +
                                     e.getMessage();
                    ErrorScreen.showError(message, display.getCurrent());
                }
                break;
        }
    }

    /**
     * SaveDiscoverability
     * Saves the current discoverability mode.
     */
    private void saveDiscoverability()
    {
        try
        {
            // Store discoverability mode
            previousDiscoverabilityMode =
                LocalDevice.getLocalDevice().getDiscoverable();
        }
        catch(Exception e)
        {
            // We will just ignore, and not try to save it.
        }
    }

    /**
     * RestoreDiscoverability
     * Restores the discoverability mode.
     */
    private void restoreDiscoverability()
    {
        try
        {   // Restore discoverability mode
            if( previousDiscoverabilityMode != -1 )
            {
                localDevice.setDiscoverable( previousDiscoverabilityMode );
            }
        }
        catch( Exception e )
        {
            // We will just ignore; there is not much we can do.
        }
    }


    /** Sets the local name that is used by the server/device (not the friendly name).
     * This can freely be chosen, it could also be the friendly name of the device.
     * @param ln Name to be used.
     */
    public void setName( String ln )
    {
        // Store service name
        localName = ln;
    }

    /** Sets the UUID for the service.
     * A UUID is made of:
     * x = random, b = BD address of one of my Bluetooth devices (because BD addresses are also unique)
     * xxxx xxxx xxxx 1xxx 8xxx bbbbbbbbbbbb
     * Eg. for my 3650 the BD address is 006057028C19. So I could invent a
     * UUID equal to "00000000000010008000006057028C19".
     * @param UUID UUID that shall be used.
     */
    public void setServiceUUID( String UUID )
    {
        // store UUID
        serviceUUID = UUID;
        // Because this is normally one of the first functions called,
        // this notification is placed here
        if( CONCEPT_SDK_BUILD )
        {   // Display note: Reminder that this is build for Conecpt SDK.
            // In build for real phones CONCEPT_SDK_BUILD should be set to false.
            Alert a = new Alert( "", "CONCEPT SDK Build", null, AlertType.INFO );
            a.setTimeout( 1000 );
            display.setCurrent( a );

            try
            {
                Thread.sleep( 1000 );
            }
            catch(InterruptedException e )
            {
                // We can just ignore
            }
        }
    }


    /** Does an Inquiry followed by a service search.
     * The user has (depending on parameter) the possibility to select one or more devices.
     * The devices are connected and a list of connections is returned.
     * @param st Defines the search type. Depending on the search type the user might have to
     * select one or more found devices. Allowed values are: <br>
     * {@link #SEARCH_CONNECT_FIRST_FOUND SEARCH_CONNECT_FIRST_FOUND},<br>
     * {@link #SEARCH_CONNECT_ALL_FOUND SEARCH_CONNECT_ALL_FOUND},<br>
     * {@link #SEARCH_ALL_DEVICES_SELECT_ONE SEARCH_ALL_DEVICES_SELECT_ONE}, and<br>
     * {@link #SEARCH_ALL_DEVICES_SELECT_SEVERAL SEARCH_ALL_DEVICES_SELECT_SEVERAL}.

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
亚洲欧美综合色| 久久色在线观看| av亚洲产国偷v产偷v自拍| 国产九九视频一区二区三区| 久久国产精品99精品国产| 天堂va蜜桃一区二区三区| 日韩精品成人一区二区在线| 亚洲综合一区二区三区| 亚洲午夜久久久久久久久电影网| 一区二区三区四区蜜桃| 亚洲妇熟xx妇色黄| 精品一区二区三区av| 国产精品一区二区视频| 成人三级伦理片| 91极品美女在线| 欧美巨大另类极品videosbest| 欧美乱熟臀69xxxxxx| 欧美一区二区三区人| 久久综合国产精品| 中文字幕av不卡| 亚洲午夜影视影院在线观看| 美腿丝袜亚洲三区| 国产成人在线免费| 欧美日韩精品一区二区三区四区 | 亚洲综合色自拍一区| 午夜精品免费在线观看| 韩国精品久久久| 波波电影院一区二区三区| 欧美午夜视频网站| 精品国产一区二区三区四区四| 国产精品色哟哟网站| 五月婷婷久久综合| 国产91在线看| 8x福利精品第一导航| 国产精品毛片大码女人 | 91精品免费观看| 国产三级精品在线| 亚洲午夜私人影院| 国产精品一区久久久久| 欧美日本国产视频| 亚洲欧洲美洲综合色网| 青青草原综合久久大伊人精品优势| 波波电影院一区二区三区| 337p亚洲精品色噜噜| 日韩理论片网站| 国内成人自拍视频| 欧美精品成人一区二区三区四区| 亚洲gay无套男同| 成人网男人的天堂| 日韩欧美国产不卡| 久久综合资源网| 国产精品久久久久久久久搜平片 | 国产精品国产三级国产普通话蜜臀 | 日本不卡中文字幕| 日韩免费性生活视频播放| 精品一区二区久久久| 中文字幕欧美国产| 在线观看免费亚洲| 美脚の诱脚舐め脚责91| 国产精品色哟哟| 在线观看亚洲精品视频| 热久久久久久久| 国产精品视频线看| 欧美日韩国产片| 国产精品主播直播| 亚洲免费在线视频一区 二区| 欧美三级电影在线观看| 激情综合色播激情啊| 亚洲精品国产一区二区精华液 | 黄色小说综合网站| 亚洲欧美日韩电影| 精品免费一区二区三区| 色综合久久中文综合久久97| 免费观看在线色综合| 一区视频在线播放| 精品国产免费人成电影在线观看四季 | 欧美系列亚洲系列| 国产一区在线看| 日韩精品电影在线| 一区二区三区四区不卡在线| 久久影音资源网| 欧美一区二区三区免费在线看| 成人一区二区三区| 美女免费视频一区二区| 亚洲精品乱码久久久久久黑人| 久久精品人人爽人人爽| 3atv一区二区三区| 欧美色图片你懂的| av成人老司机| 国产黄色91视频| 蜜桃在线一区二区三区| 亚洲国产综合在线| 最新日韩av在线| 欧美激情综合五月色丁香| 欧美一区二区黄色| 欧美人与z0zoxxxx视频| 91国产视频在线观看| 不卡的av网站| 成人av片在线观看| 国产一区二区精品久久99| 奇米精品一区二区三区四区| 亚洲风情在线资源站| 亚洲欧美一区二区三区极速播放 | 成人av动漫在线| 国产一区二区h| 极品少妇xxxx偷拍精品少妇| 日韩和的一区二区| 日韩中文字幕一区二区三区| 亚洲影院在线观看| 亚洲在线观看免费| 午夜一区二区三区视频| 亚洲一卡二卡三卡四卡| 一区二区三区美女| 一区二区三区 在线观看视频| 中文字幕亚洲一区二区va在线| 亚洲国产精品成人综合| 中国色在线观看另类| 中文无字幕一区二区三区| 欧美极品少妇xxxxⅹ高跟鞋| 亚洲国产精品t66y| 亚洲图片激情小说| 一区二区三区在线免费视频 | 欧美日韩一区二区不卡| 在线播放/欧美激情| 日韩一区二区精品| 亚洲精品一区二区三区精华液| 精品盗摄一区二区三区| 久久精品日产第一区二区三区高清版| 久久久久久久性| 中文字幕在线不卡一区| 成人欧美一区二区三区1314 | 亚洲美女偷拍久久| 亚洲午夜久久久久久久久电影网| 亚洲一二三四在线观看| 免费在线成人网| 国产成人自拍网| 91成人在线免费观看| 制服丝袜亚洲网站| 国产午夜精品在线观看| 日韩久久一区二区| 日韩国产欧美在线视频| 国产成人午夜精品5599| 色老汉av一区二区三区| 欧美精品久久久久久久久老牛影院| 日韩午夜在线影院| 国产欧美一区二区三区网站| 一区二区三区四区在线播放| 麻豆精品久久精品色综合| 成人久久18免费网站麻豆| 欧美午夜宅男影院| 国产日产亚洲精品系列| 亚洲午夜视频在线| 国产成人av资源| 欧美日韩第一区日日骚| 日本一区二区高清| 亚洲图片欧美一区| 成人黄色在线网站| 日韩欧美成人午夜| 一区二区在线观看免费视频播放| 免费成人小视频| 色婷婷综合久久| 久久色中文字幕| 日韩和欧美一区二区| 色哟哟一区二区在线观看| 精品国产不卡一区二区三区| 亚洲一二三四久久| 99综合影院在线| 久久色成人在线| 日韩1区2区3区| 日本久久电影网| 中文av字幕一区| 国产一区二区伦理| 欧美成人乱码一区二区三区| 夜夜嗨av一区二区三区| 成人精品免费视频| 久久综合精品国产一区二区三区| 婷婷成人激情在线网| 91小视频免费观看| 国产精品丝袜在线| 韩国女主播成人在线| 欧美成人a在线| 久久精品国产久精国产| 欧美精品免费视频| 亚洲综合精品久久| 欧美性猛交xxxxxxxx| 亚洲人午夜精品天堂一二香蕉| 国产成人在线看| 国产网红主播福利一区二区| 久久99蜜桃精品| 91精品国产色综合久久久蜜香臀| 亚洲福利视频导航| 欧美亚洲国产bt| 亚洲国产成人tv| 欧美日韩综合不卡| 亚洲成人av一区二区三区| 69堂亚洲精品首页| 丝袜美腿亚洲色图| 欧美一区二区三区免费在线看| 日本网站在线观看一区二区三区| 欧美午夜影院一区|