제가 액티비티에서 블루투스 맥주소를 저장하고 서비스에서 맥주소를 읽어서 자동으로 연결되게 하려고 하고 있습니다.
public String fileopen() {
String dirPath = getFilesDir().getAbsolutePath();
File file = new File(dirPath);
// 파일이 1개 이상이면 파일 이름 출력
if (file.listFiles().length > 0) {
for (File f : file.listFiles()) {
String str = f.getName();
Log.v(null, "connecting with : " + str);
// 파일 내용 읽어오기
String loadPath = dirPath + "/" + str;
try {
FileInputStream fis = new FileInputStream(loadPath);
BufferedReader bufferReader = new BufferedReader(new InputStreamReader(fis));
String content = "", temp = "";
while ((temp = bufferReader.readLine()) != null) {
content += temp;
}
Log.v(null, "" + content);
return content;
} catch (Exception e) {
return null;
}
}
}
return null;
}
함수는 이런데 파일을 읽는데 리턴으로 블루투스 주소를 넣었습니다.
이 함수를 태블릿으로 작업을 할때는 이상이 없었습니다.(4.4킷캣)
if (mChatService.getState() == BluetoothChatService.STATE_LISTEN && filecheck() == true) {
android.util.Log.d(TAG, "파일 있음" + fileopen());
connectDevice();
}
로그캣은 아래와 같은 방식으로 사용되게 됩니다.

다만 제폰(롤리팝)으로는 요런식으로 파일을 읽어오네요... 문제점을 잘 모르겠습니다...