2013-08-14 3 views
0

브로드 캐스트 수신기를 구축하려고합니다. 블루투스로 내 전화기의 변경 사항을 수신하므로 연결되어있는 장치의 신호가 없어지면 메시지 **블루투스 용 브로드 캐스트 수신기 구축 방법

+0

당신은 http://developer.android.com/reference/android/에 나열된 다음 방송 작업을 추가 할 수있는 변화가 bluetooth/BluetoothAdapter.html을 브로드 캐스트 리시버에 추가하십시오. – Milan

+0

이 링크에서 찾기 http://stackoverflow.com/a/11790366/1835231 –

+0

잘 모자 지금까지 내가 한 일은 – user2563156

답변

0

android SDK에는 블루투스 채팅 응용 프로그램 용 샘플이 내장되어 있으므로 this link을 참조하여 SDK 버전에 따라 위치를 찾을 수 있습니다.

이 파일에는 BluetoothChatService.java라는 파일이 있습니다.이 파일을 참조하십시오.이 파일에는 매우 적합한 브로드 캐스트 수신기가 내장되어 있습니다. 이 기능은 연결 상태를 가져 오는 데 사용되는 follwing을에서

, 모든 시간

/** 
    * Set the current state of the chat connection 
    * @param state An integer defining the current connection state 
    */ 
    private synchronized void setState(int state) { 
     if (D) Log.d(TAG, "setState() " + mState + " -> " + state); 
     mState = state; 

     // Give the new state to the Handler so the UI Activity can update 
     mHandler.obtainMessage(BluetoothChat.MESSAGE_STATE_CHANGE, state, -1).sendToTarget(); 
    } 



* Return the current connection state. */ 
    public synchronized int getState() { 
     return mState; 
    } 
관련 문제