안녕하세요 어찌저찌해서 앱개발 관련쪽으로 취직을 하게 된 이제 막 안드로이드를 배우고 있는 입문자입니다ㅠㅠ 질문이 하나 있습니다..
이 소스는 안드로이드 스튜디오 자체에 들어있는 블루투스 채팅 소스인데요 기능 하나만을 추가하고싶습니다.
우선 이 앱은 블루투스로 2핸드폰을 페어링 시키면 카톡처럼 서로 체팅을 할수있는 프로그램 인데요.
여기서
1번 핸드폰에서 test 라는 문자를 전송하면
2번 핸드폰에서는 test 라는 문자를 출력하고 자동으로 1번 핸드폰에 대문자 TEST 라는 문자를 전송하고 싶습니다...어떻게 수정을 해야 할까요 ㅠㅠ
public class MainActivity extends SampleActivityBase {
public static final String TAG = "MainActivity";
// Whether the Log Fragment is currently shown
private boolean mLogShown;
String test = "test";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
if (savedInstanceState == null) {
FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
BluetoothChatFragment fragment = new BluetoothChatFragment();
transaction.replace(R.id.sample_content_fragment, fragment);
transaction.commit();
}
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
@Override
public boolean onPrepareOptionsMenu(Menu menu) {
MenuItem logToggle = menu.findItem(R.id.menu_toggle_log);
logToggle.setVisible(findViewById(R.id.sample_output) instanceof ViewAnimator);
logToggle.setTitle(mLogShown ? R.string.sample_hide_log : R.string.sample_show_log);
return super.onPrepareOptionsMenu(menu);
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch(item.getItemId()) {
case R.id.menu_toggle_log:
mLogShown = !mLogShown;
ViewAnimator output = (ViewAnimator) findViewById(R.id.sample_output);
if (mLogShown) {
output.setDisplayedChild(1);
} else {
output.setDisplayedChild(0);
}
supportInvalidateOptionsMenu();
return true;
}
return super.onOptionsItemSelected(item);
}
/** Create a chain of targets that will receive log data */
@Override
public void initializeLogging() {
// Wraps Android's native log framework.
LogWrapper logWrapper = new LogWrapper();
// Using Log, front-end to the logging chain, emulates android.util.log method signatures.
Log.setLogNode(logWrapper);
// Filter strips out everything except the message text.
MessageOnlyLogFilter msgFilter = new MessageOnlyLogFilter();
logWrapper.setNext(msgFilter);
// On screen logging via a fragment with a TextView.
LogFragment logFragment = (LogFragment) getSupportFragmentManager()
.findFragmentById(R.id.log_fragment);
msgFilter.setNext(logFragment.getLogView());
Log.i(TAG, "Ready");
}
}