Hi all,
Each developer has tendency that he wants to access to all services or content of OS.By being an android developer we need to know many hidden information like deviceId,call detection ,call disconnect cause and many more.
Some of the information are provided by android but some are hidden.we can get such king of information Logcat.
each application in android OS have some logcat comment to be print,by parsing them we can easily get such kind of information.
as example following is the source code for detecting the cause of call disconnect or call drop. it is the one of the most important information which is not provided by any direct api or class.
Source code:
try {
Runtime.getRuntime().exec(LOGCAT_CMD_CLR);
logprocess = Runtime.getRuntime().exec(LOGCAT_CMD);
} catch (IOException e) {
e.printStackTrace();
isRunning = false;
}
Above code is responsible for executing the logcat.
Where
LOGCAT_CMD : logcat
(LOGCAT_CMD_CLR: logcat -c
try {
reader = new BufferedReader(new InputStreamReader(logprocess
.getInputStream()), BUFFER_SIZE);
} catch (IllegalArgumentException e) {
e.printStackTrace();
isRunning = false;
}
Above code is for retrieving log cat input stream in to reader object by doing so we can get entire logcat data in to our own reader object
line = new String[1];
try {
boolean check = true;
while (isRunning) {
line[0] = reader.readLine();
String type = line[0].substring(0, 1);
String reason = null;
String line1 = line[0].substring(2);
if (type.equalsIgnoreCase("D"))
{
String linetag = line1.substring(0, 12);
if (linetag.equalsIgnoreCase("CallNotifier")) {
if (line1.contains("cause")) {
reason = line1.split(" ")[7].split(",")[0];
IMPInComingPhoneStateListener.mCause = reason;
Log.v("call", "" + reason);
isRunning = false;
} else {
IMPInComingPhoneStateListener.mCause = "unknown";
}
}
}
}
if (check) {
Log.v("-------------", "normal");
} else {
Log.v("-------------", "abnormal");
}
} catch (IOException e) {
e.printStackTrace();
isRunning = false;
}
Above code is for parsing the log from reader object and extract the cause of call disconnction.
Here you can see that there is name CallNotifier , it is a class in android os which gives the reason of call drop. we can not use directly that class in to our project
Each developer has tendency that he wants to access to all services or content of OS.By being an android developer we need to know many hidden information like deviceId,call detection ,call disconnect cause and many more.
Some of the information are provided by android but some are hidden.we can get such king of information Logcat.
each application in android OS have some logcat comment to be print,by parsing them we can easily get such kind of information.
as example following is the source code for detecting the cause of call disconnect or call drop. it is the one of the most important information which is not provided by any direct api or class.
Source code:
try {
Runtime.getRuntime().exec(LOGCAT_CMD_CLR);
logprocess = Runtime.getRuntime().exec(LOGCAT_CMD);
} catch (IOException e) {
e.printStackTrace();
isRunning = false;
}
Above code is responsible for executing the logcat.
Where
LOGCAT_CMD : logcat
(LOGCAT_CMD_CLR: logcat -c
try {
reader = new BufferedReader(new InputStreamReader(logprocess
.getInputStream()), BUFFER_SIZE);
} catch (IllegalArgumentException e) {
e.printStackTrace();
isRunning = false;
}
Above code is for retrieving log cat input stream in to reader object by doing so we can get entire logcat data in to our own reader object
line = new String[1];
try {
boolean check = true;
while (isRunning) {
line[0] = reader.readLine();
String type = line[0].substring(0, 1);
String reason = null;
String line1 = line[0].substring(2);
if (type.equalsIgnoreCase("D"))
{
String linetag = line1.substring(0, 12);
if (linetag.equalsIgnoreCase("CallNotifier")) {
if (line1.contains("cause")) {
reason = line1.split(" ")[7].split(",")[0];
IMPInComingPhoneStateListener.mCause = reason;
Log.v("call", "" + reason);
isRunning = false;
} else {
IMPInComingPhoneStateListener.mCause = "unknown";
}
}
}
}
if (check) {
Log.v("-------------", "normal");
} else {
Log.v("-------------", "abnormal");
}
} catch (IOException e) {
e.printStackTrace();
isRunning = false;
}
Above code is for parsing the log from reader object and extract the cause of call disconnction.
Here you can see that there is name CallNotifier , it is a class in android os which gives the reason of call drop. we can not use directly that class in to our project