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

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

?? bluetooth.java

?? 手機藍牙驅動和應用實例源碼
?? JAVA
?? 第 1 頁 / 共 3 頁
字號:

//#ifdef useBT
import javax.microedition.lcdui.*;
import javax.microedition.io.*;
import java.io.*;

import javax.bluetooth.*;
import java.util.Vector;
//#endif

class BlueTooth
{
//#ifdef useBT
    // Bluetooth/JSR82 variables
    private LocalDevice localDevice = null; // Reference to LocalDevice
    private int previousDiscoverabilityMode = -1; // Used to restore discoverabilty mode afterwards

    static public final boolean CONCEPT_SDK_BUILD = false;
    // 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;

    // 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 	= "20000000000010008000006057028C19";
    private String localName 	= null;    // The name of the device/service

    private String warning; // Warnign presented to the user in case no device or no service was found

    private static BluetoothConnection[] btConnections;  // All Bluetooth connections
    private StreamConnectionNotifier notifier;  // For the server

    private Vector urlStrings; // This holds the url strings of the returned services
    private DeviceList deviceList;  // List with devices that is shown to the user.
    private DiscoveryAgent discoveryAgent; // Reference to DiscoveryAgent (used for Inquiry)
    private Listener listener; // Discovery Listener (used for inquiry)
    private Vector foundServiceRecords; // holds all the found service records
    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 int maxDevices; // Number of max. connectable devices (retrieved by getproperty)
	public static StringBuffer ErrorMessage = new StringBuffer("");

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

    public static int lastSent;
    public static int gotInt;
	public static boolean bReadReady;
	public static boolean recThread;
//#endif
	public static boolean ConnectCancelled = false;
    public static boolean gameFound;

	BlueTooth()
	{
//#ifdef useBT
		//System.out.println("BTHere1");
        try
        {
            // Create object used to synchronize/lock
	        block_r = new Object();
	        block_c = new Object();
	        block_s = new Object();
	        block_ss = new Object();
	        block_notifier = new Object();
	        // Obtain local device object
            localDevice = LocalDevice.getLocalDevice();
    		//System.out.println("BTHere2");
            // Retrieve number of connectable devices
            maxDevices = Integer.parseInt( LocalDevice.getProperty( "bluetooth.connected.devices.max" ) );
    		//System.out.println("BTHere3");
            // Because of definition with parked devices
            if( maxDevices > 2 )
            {   // limit to 2
                maxDevices = 2;
            }
        }
        catch(Exception e)
        {   // not much that can be done
            localDevice = null;

            ErrorMessage.append("Error trying to get local device properties: ");
            ErrorMessage.append(e.getMessage());
            return;
//            ErrorScreen.showError(message, display.getCurrent());
        }
        // Set UUID
		//System.out.println("BTHere4");
        //setServiceUUID( "20000000000010008000006057028C19" );

        // Check if Bluetooth is turned on
        String name;
        try
        {
            name = LocalDevice.getLocalDevice().getFriendlyName();
    		//System.out.println("BTHere5");
        }
        catch( BluetoothStateException e )
        {   // display user notification
            ErrorMessage.append("Please switch Bluetooth on!");
            return;
        }
		//System.out.println("BTHere6");
        // Sets the name how this device is shown to the remote user
        setName( name );
//#endif
	}

	public static boolean isConnected()
	{
//#ifdef useBT

		try
		{
			if (btConnections[0] == null) return false;
			if (BlueTooth.btConnections[0].isClosed()) return false;
		}
		catch (Exception e)
		{
			return false;
		}
//#endif
		return true;
	}

	public int retrieve()
	{
		int inp = 0;
//#ifdef useBT
		inp = BlueTooth.gotInt;
		if (!bReadReady)
		{
			bReadReady = true;
			synchronized( block_r )
	        {
	            block_r.notify();
	        }
		}
//#endif
		return inp;
	}

	public static void send(int c)
	{
//#ifdef useBT
	    try
	    {
	    	lastSent = c;
	    	btConnections[0].writeInt(c);
	    }
	    catch( IOException e )
	    {   // If error, then close
//	        btConnections[0].close();
	        // Check if all connections are closed
//	        if( checkIfAllClosed() )
	        {   // all closed -> return
//	            return;
	    		//System.out.println("Send Error");
	        }
	    }
	    catch (Exception e)
		{

		}
//#endif
	}

	public static void resend()
	{
//#ifdef useBT
		send(lastSent);
//#endif
	}

	public void startReceive()
	{
//#ifdef useBT
		recThread = true;
        // Start Server
        ReceiveThread rt = new ReceiveThread(0);
        rt.start();
//#endif
	}

	public void hostGame()
	{
//#ifdef useBT
		initGame();
        // Start Server
        ServerThread st = new ServerThread();
        st.start();
//#endif
	}

	public void joinGame()
	{
//#ifdef useBT
		initGame();
	    ClientThread ct = new ClientThread( SEARCH_CONNECT_FIRST_FOUND );
	    ct.start();
//#endif
	}

	private static void initGame()
	{
//#ifdef useBT
    	ConnectCancelled = false;
    	lastSent = 0;
    	gotInt = -1;
		bReadReady = false;
		recThread = false;
	    gameFound = false;
//#endif
	}

	public void interuptServer(boolean bHost)
	{
//#ifdef useBT
		try
		{
			if (bHost)
			{
		        synchronized( block_s )
				{
		        	block_s.notify();
				}
			}
			else
			{
		        synchronized( block_c )
				{
		        	block_c.notify();
				}
			}
		}
		catch (Exception e)
		{
            ErrorMessage.append("XXX");
            ErrorMessage.append(e);
    		//System.out.println("interuptServer Error " + e.getMessage());
		}
//#endif
	}


//#ifdef useBT
    // Innerclass
    /** The ServerThread is used to wait until someone connects. <br
     * A thread is needed otherwise it would not be possible to display
     * anything to the user.
     */
    private class ServerThread
    extends Thread
    {
        /**
         * This method runs the server.
         */
        public void run()
        {
    		//System.out.println("BTHere7");
            try
            {
                // Wait on client
                BluetoothConnection[] con = waitOnConnection();
        		//System.out.println("BTHere8");
                if( con[0] == null )
                {   // Connection cancelled
                	ErrorMessage.append("Connection Cancelled.");
                	ConnectCancelled = true;
                	//System.out.println("BTHere9 Cancelled");
                }
            	else
            	{
           			gameFound = true;
            		//System.out.println("BTHere9 Connection OK -");
            	}

                // Create Canvas to display keystrokes
//                nc = new NumberCanvas( con );

                // Set as new display
//                display.setCurrent( nc );
            }
            catch (BluetoothStateException e)
    		{
        		//System.out.println("BTHere10 BluetoothStateException " + e.getMessage());
               	ConnectCancelled = true;
    		}
            catch (IOException e)
    		{
        		//System.out.println("BTHere10 IOException " + e.getMessage());
               	ConnectCancelled = true;
    		}
            catch( InterruptedException e )
            {    // display error message
                ErrorMessage.append("Error:");
                ErrorMessage.append(e.getMessage());
        		//System.out.println("BTHere10 " + e.getMessage());
               	ConnectCancelled = true;
                return;
            }
            catch (Exception e)
    		{
        		//System.out.println("BTHere10 Exception " + e.getMessage());
               	ConnectCancelled = true;
    		}
        }
    }
    private class ClientThread
    extends Thread
    {
        // Search type
        private int searchType;

        /** Constructor
         * @param st The search type. Possible values:
         * {@link BluetoothDiscovery.SEARCH_CONNECT_FIRST_FOUND SEARCH_CONNECT_FIRST_FOUND},
         * {@link BluetoothDiscovery.SEARCH_CONNECT_ALL_FOUND SEARCH_CONNECT_ALL_FOUND},
         * {@link BluetoothDiscovery.SEARCH_ALL_DEVICES_SELECT_ONE SEARCH_ALL_DEVICES_SELECT_ONE},
         * {@link BluetoothDiscovery.SEARCH_ALL_DEVICES_SELECT_SEVERAL SEARCH_ALL_DEVICES_SELECT_SEVERAL}.
         */
        protected ClientThread( int st )
        {
            // store search type
            searchType = st;
        }


        /**
         * This method runs the client.
         */
        public void run()
        {
            try
            {
                BluetoothConnection conn[] = searchService( searchType );
                if( conn.length != 0 )
                {
           			gameFound = true;
                	//System.out.println("Join Game Connection OK -");
                }
                else
                {   // nothing found
                	ConnectCancelled = true;
                	//System.out.println("Join Game Connection Not OK -");
                }
            	//System.out.println("Join Game Connection Done -");
            }
            catch( Exception e )
            {    // display error message
                ErrorMessage.append("Error:");
                ErrorMessage.append(e.getMessage());
        		//System.out.println("ClientThread Exception " + e.getMessage());
               	ConnectCancelled = true;
                return;
            }
        }
    }

    /** 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
                {

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
中文字幕永久在线不卡| 亚洲国产日韩a在线播放| 1024成人网色www| 成人一区二区三区在线观看| 91麻豆高清视频| 亚洲成a人v欧美综合天堂下载 | 91在线观看视频| 欧美精品1区2区3区| 国产人久久人人人人爽| 肉肉av福利一精品导航| 一本色道久久综合亚洲精品按摩| 欧美大肚乱孕交hd孕妇| 亚洲国产精品综合小说图片区| 大桥未久av一区二区三区中文| 日韩无一区二区| 婷婷六月综合网| 在线精品视频一区二区三四| 国产精品免费aⅴ片在线观看| 麻豆精品一区二区| 欧美精品18+| 日韩专区在线视频| 欧美视频日韩视频| 亚洲欧美日韩国产综合| av一二三不卡影片| 日本一区二区三级电影在线观看| 丝袜亚洲精品中文字幕一区| 欧洲一区二区三区在线| 一区二区三区四区视频精品免费| 成人免费av在线| 国产精品不卡一区| 成人精品免费网站| 国产精品久久毛片| 成人av电影免费在线播放| 国产精品私房写真福利视频| 国产成人av影院| 国产精品污网站| 成人三级伦理片| 综合欧美一区二区三区| 色狠狠桃花综合| 一区二区久久久久| 欧美性欧美巨大黑白大战| 亚洲狠狠爱一区二区三区| 欧美日韩亚洲综合一区| 亚洲伊人伊色伊影伊综合网| 欧美群妇大交群中文字幕| 日本成人在线视频网站| 亚洲精品一线二线三线| 成人综合婷婷国产精品久久蜜臀| 国产精品视频第一区| 97精品久久久久中文字幕| 亚洲自拍偷拍欧美| 欧美一区二区三区免费观看视频| 美女网站一区二区| 国产欧美一区在线| 色悠悠久久综合| 日韩成人精品在线| 国产日产精品一区| 色综合久久久久久久| 日日骚欧美日韩| 久久久久久9999| 日本道精品一区二区三区| 日韩电影免费一区| 国产精品另类一区| 欧美喷水一区二区| 国产成人在线色| 亚洲电影你懂得| 日本一区二区三区电影| 欧美三区在线视频| 国产一区亚洲一区| 亚洲黄色av一区| 久久免费的精品国产v∧| 日本乱人伦一区| 经典三级在线一区| 亚洲午夜久久久| 欧美激情一区在线| 欧美精品国产精品| 丁香婷婷综合五月| 日本特黄久久久高潮| 中文字幕在线一区免费| 日韩欧美一二三区| 欧洲生活片亚洲生活在线观看| 久久成人羞羞网站| 亚洲一区中文在线| 中文字幕成人av| 日韩欧美一二区| 欧美日韩一区二区三区四区| 国产a区久久久| 狂野欧美性猛交blacked| 亚洲最色的网站| 中文字幕欧美激情| 久久免费的精品国产v∧| 欧美久久久久久久久| av男人天堂一区| 国产东北露脸精品视频| 美女网站在线免费欧美精品| 亚洲福利一区二区| ●精品国产综合乱码久久久久| 精品国产一区二区国模嫣然| 69久久99精品久久久久婷婷 | 国产一区在线精品| 婷婷综合在线观看| 亚洲一区欧美一区| 国产精品三级av在线播放| 日韩限制级电影在线观看| 成人av在线资源| 综合亚洲深深色噜噜狠狠网站| 中文成人综合网| 亚洲精品一区二区三区四区高清| 在线视频欧美区| 国产成人av影院| 久久丁香综合五月国产三级网站| 丝袜脚交一区二区| 亚洲激情成人在线| 日韩一区在线看| 国产女人aaa级久久久级| 宅男在线国产精品| 欧美日韩综合不卡| 91成人免费网站| 色综合久久久网| 91香蕉视频污| 91免费观看在线| 成人综合婷婷国产精品久久| 成人高清免费观看| 国产麻豆9l精品三级站| 国产在线视频一区二区| 精品一区二区三区不卡| 婷婷中文字幕一区三区| 久久精品噜噜噜成人av农村| 日韩国产精品久久| 肉丝袜脚交视频一区二区| 视频一区中文字幕| 日韩av中文字幕一区二区| 日韩中文字幕1| 日韩精品国产欧美| 日精品一区二区三区| 日韩国产一区二| 青青国产91久久久久久| 日韩激情一区二区| 亚洲狠狠爱一区二区三区| 国产精品久久久久一区| 综合色天天鬼久久鬼色| 国产精品白丝在线| 国产精品青草综合久久久久99| 一区二区三区在线看| 亚洲免费大片在线观看| 亚洲国产日韩在线一区模特| 日韩av在线免费观看不卡| 久久国产麻豆精品| 色拍拍在线精品视频8848| 91丝袜高跟美女视频| 在线观看免费亚洲| 欧美一区二区私人影院日本| 51午夜精品国产| 国产精品高潮呻吟| 亚洲福利视频导航| 久久精品国产一区二区三| 国产高清亚洲一区| 99久久99久久综合| 精品欧美久久久| 日韩一区欧美小说| 奇米影视一区二区三区小说| 秋霞午夜鲁丝一区二区老狼| 91在线视频官网| 欧美日韩综合不卡| 精品国内二区三区| 1000部国产精品成人观看| 亚洲三级在线免费| jlzzjlzz欧美大全| 精品少妇一区二区三区视频免付费| 精品99久久久久久| 中文字幕五月欧美| 欧美96一区二区免费视频| 国产不卡视频在线播放| 91极品视觉盛宴| 久久一区二区三区四区| 亚洲男同性恋视频| 日韩**一区毛片| av在线综合网| 日韩久久精品一区| 亚洲在线视频网站| 国产又粗又猛又爽又黄91精品| 国产精品伊人色| 日韩欧美国产三级电影视频| 亚洲另类一区二区| 韩国精品主播一区二区在线观看| 欧美综合亚洲图片综合区| 日韩欧美aaaaaa| 狂野欧美性猛交blacked| 日本道免费精品一区二区三区| 久久精品一区二区三区不卡 | 成人性生交大片免费看在线播放 | 884aa四虎影成人精品一区| 国产欧美一区二区精品性色超碰 | 91精品国产福利在线观看| 日韩一区中文字幕| 久久99国产乱子伦精品免费| 91精品国产综合久久久久久| 一区二区三区在线视频观看58| 国产美女在线观看一区| 久久噜噜亚洲综合|