RT,怎么run里面的while函数会退出呢?str_all数组里只有200多个,然后str就成null了,然后就退出了~public class holdon_listener extends PhoneStateListener {
@Override
public void onCallStateChanged(int state, String incomingNumber){
super.onCallStateChanged(state, incomingNumber);
if((state == TelephonyManager.CALL_STATE_OFFHOOK)&(firstcall)){
mhandler.postDelayed(mrun, 1000);
firstcall = false;
}
else if((state == TelephonyManager.CALL_STATE_IDLE)&(!(firstcall)))
{
firstcall = true;
}
}
}private Handler mhandler = new Handler();
private Runnable mrun = new Runnable(){
@SuppressWarnings("null")
@Override
public void run() {
// TODO Auto-generated method stub
System.out.println("--------func start--------"); // 方法启动
try
{
ArrayList<String> cmdLine=new ArrayList<String>(); //设置命令 logcat -d 读取日志
cmdLine.add("logcat");
cmdLine.add("-d");
ArrayList<String> clearLog=new ArrayList<String>(); //设置命令 logcat -c 清除日志
clearLog.add("logcat");
clearLog.add("-c");
Process process=Runtime.getRuntime().exec(cmdLine.toArray(new String[cmdLine.size()])); //捕获日志
BufferedReader bufferedReader=new BufferedReader(new InputStreamReader(process.getInputStream())); //将捕
String str = "";
String str_all[] = new String [1000];
int ii = 0;
while((str = bufferedReader.readLine())!=null)
{
Runtime.getRuntime().exec(clearLog.toArray(new String[clearLog.size()]));
str_all[ii] = str;
if(str==null)
{
System.out.println("-- is null --");
}
ii++;
}
ii = ii +1;
} catch (IOException e)
{
e.printStackTrace();
System.out.println("--------str wrong--------");
}
System.out.println("--------func end--------");
}
@Override
public void onCallStateChanged(int state, String incomingNumber){
super.onCallStateChanged(state, incomingNumber);
if((state == TelephonyManager.CALL_STATE_OFFHOOK)&(firstcall)){
mhandler.postDelayed(mrun, 1000);
firstcall = false;
}
else if((state == TelephonyManager.CALL_STATE_IDLE)&(!(firstcall)))
{
firstcall = true;
}
}
}private Handler mhandler = new Handler();
private Runnable mrun = new Runnable(){
@SuppressWarnings("null")
@Override
public void run() {
// TODO Auto-generated method stub
System.out.println("--------func start--------"); // 方法启动
try
{
ArrayList<String> cmdLine=new ArrayList<String>(); //设置命令 logcat -d 读取日志
cmdLine.add("logcat");
cmdLine.add("-d");
ArrayList<String> clearLog=new ArrayList<String>(); //设置命令 logcat -c 清除日志
clearLog.add("logcat");
clearLog.add("-c");
Process process=Runtime.getRuntime().exec(cmdLine.toArray(new String[cmdLine.size()])); //捕获日志
BufferedReader bufferedReader=new BufferedReader(new InputStreamReader(process.getInputStream())); //将捕
String str = "";
String str_all[] = new String [1000];
int ii = 0;
while((str = bufferedReader.readLine())!=null)
{
Runtime.getRuntime().exec(clearLog.toArray(new String[clearLog.size()]));
str_all[ii] = str;
if(str==null)
{
System.out.println("-- is null --");
}
ii++;
}
ii = ii +1;
} catch (IOException e)
{
e.printStackTrace();
System.out.println("--------str wrong--------");
}
System.out.println("--------func end--------");
}
public class holdon_listener extends PhoneStateListener {
@Override
public void onCallStateChanged(int state, String incomingNumber){
super.onCallStateChanged(state, incomingNumber);
if((state == TelephonyManager.CALL_STATE_OFFHOOK)&(firstcall)){
mhandler.postDelayed(mrun, 1000);
firstcall = false;
}
else if((state == TelephonyManager.CALL_STATE_IDLE)&(!(firstcall)))
{
firstcall = true;
}
}
}调用方法有问题?