안드로이드 개발 질문/답변
(글 수 45,052)
앱을 실행하면 문자를 사용못하게 하는 앱을 만들고 있는데
하는 방식은 시스템의 로그를
private void runLog()
{
// TODO Auto-generated method stub
Process process = null;
//Log.e("Thard Start !!!!!!!!!!!!",null);
try
{
//현재까지의 로그를 모두 지운다
Runtime.getRuntime().exec("/system/bin/logcat -c");
//로그읽기 시작
process = Runtime.getRuntime().exec(
"/system/bin/logcat -b main -s ActivityManager:I");
}
catch(IOException e)
{
Log.e(getPackageName(),e.toString());
}
BufferedReader reader = null;
try
{
reader = new BufferedReader(new InputStreamReader(process.getInputStream()));
String line;
while (mStop) {
line = reader.readLine();
// 액티비티 시작로그 잡아내기
// 패키지 이름으로 필터링
for (int i = 0; i < mPackageFilter.size(); i++) {
if (line.matches( ".*"+mPackageFilter.get(i)+".*")) {
if (!mPassApp)
{
popupLock(mPackageFilter.get(i));
} else {
mPassApp = false;
}
}
}
}
}
catch(IOException e)
{
Log.e(getPackageName(),e.toString());
}
finally
{
try
{
reader.close();
}catch (IOException e)
{
// TODO Auto-generated catch block
Log.e(getPackageName(),e.toString());
}
process.destroy();
process = null;
if(mStop != true)
{
mThread.stop();
mThread.destroy();
}
reader = null;
this.stopSelf();
}
}
현제 에뮬레이터에서는 잘 작동합니다만 제가 가지고 있는 ARC에서는 처음에 메시지 버튼을 누르면 되고 2번째 메시지 버튼을
누르면 작동을 안하다가 백버튼을 누르고 다시 메시지 버튼을 누르면 실행합니다. ㅠㅠ .........
왜 그런지 아시는분좀 알려주세요 ㅠ
자문 자 답입니다. 아직 정확하게 커맨드를 분석하지는 못하였지만 위 문제는 해결 했습니다.
"/system/bin/logcat -b main -s ActivityManager:I"
);
이 이 부분에서
"/system/bin/logcat ActivityManager:I"
)을 지우고 실행하면 터치할때마다 로그파일을 읽어왔습니다.
이
이