Problems trying to obtain incoming call details

Post your questions and help other users.

Moderator: Martin

Post Reply
andrewmoni
Posts: 8
Joined: 11 Sep 2013 07:55

Problems trying to obtain incoming call details

Post by andrewmoni » 23 Sep 2013 08:20

I thought this would be simple - but I'm tearing my hair out! I wanted to have a flow that triggered with an incoming call and announced the caller if in contacts or read the number out if not in contacts or said private number if no CID present.
I am triggering without a problem using the ringing call state, and I then init variables from call log for new call. The problem is that the details I pick up appear to be from the previous completed call rather than the current incoming call.
How do I obtain the current incoming details in automagic - which are displayed correctly on the screen by the phone??

Hits head I think for being so stupid .... it helps to use the correct variables!!

Solved I think, and hope, by a) forgetting call log and initialising variables and b) using caller_number and contact_name.

Still one niggle left though - how to make speech output give the phone number digit by digit rather than something like 25 million 300 thousand ....... - anyone got any tricks or methods for this??

I am using conditions
a) length(contact_name) > 0 to say if the caller is in contacts list, and
b) caller_number > 0 to see if number present.
Are these the correct tests to make or should I be doing something else?

Now I have been still getting stuck trying to break the number into digits. I got it to work in Tasker, but just cannot work out how to do it with automagic. It should be possible to create a list of digits by using the split function, but I just cannot get the format for the regular expression for the pattern to make a list of single character entries from the original calling number.

Please please - anyone got any ideas??

User avatar
Martin
Posts: 4468
Joined: 09 Nov 2012 14:23

Re: Problems trying to obtain incoming call details

Post by Martin » 23 Sep 2013 16:45

You can use the function replaceAll to replace all matching substrings (each digit) with a digit plus a whitespace character. Something like this:
number = "1234567";
separated = replaceAll(number, "(.)", "$1 ");

The variable separated will contain the string "1 2 3 4 5 6 7 ".

andrewmoni
Posts: 8
Joined: 11 Sep 2013 07:55

Re: Problems trying to obtain incoming call details

Post by andrewmoni » 23 Sep 2013 18:24

Martin you are a genius!!

That worked just fine - but leaves me with two questions - where can I find out more on the syntax of functions and where on earth are such things as the $1 documented??

The replaceAll is what I started trying but just had the syntax/format completely wrong. I never had the period inside brackets and as for the $1 ... well ... am just blown away.

After a whole day of ten thousand variations on a theme the closest I got was breaking into a list - but when the list was passed to the speech it was giving me "squasre bracket nine nine two three closing square bracket" in speach ....

User avatar
Martin
Posts: 4468
Joined: 09 Nov 2012 14:23

Re: Problems trying to obtain incoming call details

Post by Martin » 23 Sep 2013 19:29

The functions are very briefly documented on the help page of action Script.

Many of the regex-functions like split, replaceAll directly delegate the call to the corresponding java function. The javadoc page of the Pattern class is very helpful: Pattern
I didn't really find the source where the $1 part is documented. It probably has it's origin here: Javadoc Matcher class

It's on my todo-list to create a dedicated help page for the regex functions.

andrewmoni
Posts: 8
Joined: 11 Sep 2013 07:55

Re: Problems trying to obtain incoming call details

Post by andrewmoni » 24 Sep 2013 12:18

Martin - after checking both the references you gave I think some help which is in practical layman's terms would be just what is needed. Those two pages did not help one little bit I am afraid to say!!!

Post Reply