728x90
Android 에서 파일에 LogData를 기록할 목적으로 만든 코드이다.
public static void dataSaveLog(String _log, String _fileName) {
/* SD CARD 하위에 LOG 폴더를 생성하기 위해 미리 dirPath에 생성 할 폴더명을 추가 */
String dirPath = Environment.getExternalStorageDirectory().getAbsolutePath() + "/LOG/";
File file = new File(dirPath);
// 일치하는 폴더가 없으면 생성
if (!file.exists())
file.mkdirs();
// txt 파일 생성
File savefile = new File(dirPath + "LOG_" + _fileName + ".txt");
try {
BufferedWriter bfw = new BufferedWriter(new FileWriter(dirPath + "LOG_" + _fileName + ".txt", true));
bfw.write(_log);
bfw.write("\n");
bfw.flush();
bfw.close();
} catch (IOException e){
/* Exception */
}
}
|
Android 11 에서 USB 케이블 없이 Wi-Fi 로 연결하여 콘솔앱에서 출력되는 메시지를 확인할 수 있어서
지금은 위 코드를 굳이 사용할 필요는 없어졌다.
Android Studio 에서 ADB를 이용하여 LogCat 정보를 확인하는 방법
adb tcpip 5555
// 192.168.1.32 는 스마트폰이 연결된 Wi-Fi 주소
adb connect 192.168.1.32:5555
728x90
'안드로이드 > Android Serial 통신' 카테고리의 다른 글
Geateway 파싱 처리 (0) | 2020.05.23 |
---|---|
AlertDialog EditText (0) | 2019.06.26 |
Android 팝업창(popup window) 만들기 (0) | 2019.06.01 |
android handler 를 이용한 지연처리 (0) | 2019.05.09 |
Serial Communication Key (0) | 2019.05.09 |