public void onReceive(Context arg0, Intent arg1) {
Toast.makeText(arg0, "Alarm received!", Toast.LENGTH_LONG).show(); // Vibrate the mobile phone Vibrator vibrator = (Vibrator) arg0.getSystemService(Context.VIBRATOR_SERVICE); vibrator.vibrate(2000);
메인 클래스에서 onReive를 호출하게 되서 알람 시간이 되면 진동이 울리도록 되어있는데...
현재 블루투스랑 연동해놔서... 진동이 울림이 동시에 message를 보내려고 하는데... 잘 안되네요...
위 소스에서
mainActivity blueMain = new mainActivity();
blueMain.sendMessage(msg);
를 추가 해봤는데...
진동과 함께 오류가 뜨구요...
검색하다가 따로 클래스를 만들어서 context 로 불러오라고 해서
public class BlueSend extends AndroidTimeActivity{
public void test(){
AndroidTimeActivity send = new AndroidTimeActivity();
}
}
로 클래스 만들고
BluetoothSend aaaa = (BlueSend)arg0.getApplicationContext();
aaaa.test();
로 수정 추가했는데도 에러가 뜨네요...
아 어떻게 해야할지 막막하네요...
sendMessage 는
public void sendMessage(String message) {
// Check that we're actually connected before trying anything
if (mChatService.getState() != BluetoothChatService.STATE_CONNECTED) {
Toast.makeText(this, R.string.not_connected, Toast.LENGTH_SHORT)
.show();
return;
}
// Check that there's actually something to send
if (message.length() > 0) {
// Get the message bytes and tell the BluetoothChatService to write
byte[] send = message.getBytes();
mChatService.write(send);
// Reset out string buffer to zero and clear the edit text field
mOutStringBuffer.setLength(0);
mOutEditText.setText(mOutStringBuffer);
}
}
인데...
if (mChatService.getState() != BluetoothChatService.STATE_CONNECTED) { -> 이부분이 에러나는것 같아요...
분명 블루투스 연결이 되어있는데... 왜 여기서 에러가 나는지...