채팅앱인데요~ 메시지가 수신되었을때 알림음과 진동이 뜨고 대화상자가 뜨게됩니다.
하지만 지금 제 코딩으로는, 수신받았을시 다이얼로그가 무진장많이뜨는데, 한번만 뜨게할수있을까요??
그리고 알림음을 다이얼로그에서 확인버튼을 누를때까지만 나오도록 설정할수있는방법이있을까요??
코딩은 수신부는 이렇습니다
--------------------------------------------------------------------------------------------------------------------------------------
case MESSAGE_READ:
byte[] readBuf = (byte[]) msg.obj;
// construct a string from the valid bytes in the buffer
String readMessage = new String(readBuf, 0, msg.arg1);
mConversationArrayAdapter.add(mConnectedDeviceName+": " + readMessage);
//진동
Vibrator vibrator = (Vibrator)getSystemService(Context.VIBRATOR_SERVICE);
long milliseconds = 2000;
vibrator.vibrate(milliseconds);
//알림음
//int play(int soundID, float leftVolume, float rightVolume, int priority, int loop, float rate)
//soundId= load가리턴한 식별자, Volume=사운드크기, loop=반복모드, 지정값+1회, -1이면 무한반복
//rate= 1정상속도, 0.5중간속도, 2 2배속도
beep.play(bee,1,1,0,-1,2);
//대화상자
AlertDialog.Builder ab = null;
ab = new AlertDialog.Builder( BluetoothChat.this );
ab.setMessage( "아이상태를 확인하세요!!!!");
ab.setPositiveButton(android.R.string.ok, null);
ab.setTitle( "Smart Crib" );
ab.show();
break;