简体   繁体   中英

How to detect unknown phone number in call logs (android provider)

I would like to detect the unknown phone number in my call logs list.

An unknown number on the phone is either -1 or -2 .

My question is how to detect this type of call ?.

I try to detect with :

number = Integer.parseInt(number);
if(number < 0){

}

but it is not working.

Try the following:

1) Log everything.

Put

  Log.debug("ClassName", "number = " +number);

2) number = Integer.parseInt(number); does not look quite right. try

assuming incomingPhoneNumber is defined as a String.

   String incomingPhoneNumber;

   try{

     int phoneNumber = Integer.parseInt(incomingPhoneNumber);

    }catch (Exception e) {
      Log.debug("ClassName", "error = "+e.getMessage());
      }

in eclipse you need to goto window -->Show View --> Logcat to and examine the log message but you should also just set breakpoints and run in debug mode. Step one line at a time.

Tell us if you get a negative number for the incoming call.

3) Place breakpoints at the very beginning and run in debug mode. Tell us what you get.

4) Communicate with the user questions. People are trying to help but you need to answer our questions for us to help you. For example we do need to see the definition for number to know if the code is going to work.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM