ログへのエントリをリッスンすることは可能ですか? つまり、ログ エントリが追加されたときのブロードキャスト インテントはありますか?
2 に答える
2
意図はありません。
以下のコードを使用してください:
try
{
Process mLogcatProc = null;
BufferedReader reader = null;
mLogcatProc = Runtime.getRuntime().exec(new String[]{"logcat", "-d"});
reader = new BufferedReader(new InputStreamReader(mLogcatProc.getInputStream()));
String line;
final StringBuilder log = new StringBuilder();
String separator = System.getProperty("line.separator");
while ((line = reader.readLine()) != null)
{
log.append(line);
log.append(separator);
}
String w = log.toString();
Toast.makeText(getApplicationContext(),w, Toast.LENGTH_LONG).show();
}
catch (Exception e)
{
Toast.makeText(getApplicationContext(), e.getMessage(), Toast.LENGTH_LONG).show();
}
そしてあなたはそれの許可が必要になります:
android.permission.READ_LOGS
于 2011-08-30T07:31:14.407 に答える
1
「ログ」が LogCat を意味する場合、いいえ、LogCat にIntents
エントリを追加するためのブロードキャストはありません。
于 2010-08-22T23:30:01.670 に答える