Cell Near versus Java getAllCellInfo ()

902 views
Skip to first unread message

Dirk De Preter

unread,
Dec 19, 2014, 1:28:16 PM12/19/14
to tas...@googlegroups.com
Cell Near is not working well for me (Nexus 5 / Lollipop) because no cell updates are getting through while screen is off : Cell Near based profiles don't trigger until the screen is turned on.
I had experimented with all possibly related tasker/android settings workarounds (except the ugly "screen on" workaround), and had given up on Cell Near.

But today I have experimented with the new Java support.  With getAllCellInfo (TelephonyManager), I can actually get updated cell info while the screen is off !   I'm planning on writing my own Cell-Near-like function based on this.  

Does anyone have any idea why the Java functions achieve more than what Cell Near can do ? (I'm no android developer, far from it.)

Also, my homebrew Cell Near function would run time-based (like "every 10 minutes").  But that would not be in sync with the "all checks seconds" wake-up.  I guess for the sake of battery life it would be best to synchronize this (?)  Anyone knows how to achieve this ?  (I'm thinking perhaps a boolean with cooldown time.  Who has better ideas ?)


Pent

unread,
Dec 19, 2014, 2:58:06 PM12/19/14
to tas...@googlegroups.com

But today I have experimented with the new Java support.  With getAllCellInfo (TelephonyManager), I can actually get updated cell info while the screen is off !   I'm planning on writing my own Cell-Near-like function based on this.  

That should also be possible if you select Use New Cell API in Monitor settings in Tasker.

Does anyone have any idea why the Java functions achieve more than what Cell Near can do ? (I'm no android developer, far from it.)

Maybe you had power plugged in at the time ?

Pent

Dirk De Preter

unread,
Dec 20, 2014, 5:39:00 AM12/20/14
to tas...@googlegroups.com
 
Hi Pent, FYI I have done a test run today (with New Cell API, unplugged), simulateously running following profiles : 
1. a conventional Cell Near
2. a time-based profile reporting %CellID
3. a time-based profile with getAllCellInfo used inside the task.
Profiles report their findings via Notification while screen is off.

Only profile 3 detects and reports changes of cell information while screen is off. 
The others just don't react to the changes.  (All Checks set to a frequent 80 secs though.)

Pent

unread,
Dec 20, 2014, 6:17:16 AM12/20/14
to tas...@googlegroups.com
Hmm, looking at the code, I can see a possibility of what's going on there.

Could you send me a log of just the cell near state (all the other
cell stuff disabled) ?

http://tasker.dinglisch.net/userguide/en/faqs/faq-how.html#x2

(leave it for a couple of monitor display-off checks)

Thanks,

Pent

Pent

unread,
Dec 20, 2014, 6:29:50 AM12/20/14
to tas...@googlegroups.com
Nevermind, let me make some changes first.

Pent

Nick77

unread,
Dec 22, 2014, 6:03:46 AM12/22/14
to tas...@googlegroups.com
Hi there, how can i use use java function "getAllCellInfo" ?
i'm a totally newbie to java... 
I tried with code -> java function -> under "class" i selected "TelephonyManager" , but under "function" i can't find "getAllCellInfo" in the magnifying glass...

where am i wrong ??
thanks

Pent

unread,
Dec 22, 2014, 6:40:25 AM12/22/14
to tas...@googlegroups.com


i'm a totally newbie to java... be

Probably  best to wait and see if I can find a builtin solution first then.

Pent

Nick77

unread,
Dec 22, 2014, 6:43:38 AM12/22/14
to tas...@googlegroups.com

yep of course..just wanting to train a little with this new fantastic feature :)
thks for all the great work you've done so far , by the way !

Dirk De Preter

unread,
Dec 22, 2014, 2:47:31 PM12/22/14
to tas...@googlegroups.com
It's a two step process.

In a first task, select CONTEXT under the coffee cup.  As Function, select getSystemService {Object}(String).  Under Param, write phone.  This creates a telephony manager object.  Under Return, write (TelephonyManager) myobj.  Here, myobj is a name for the object which you choose freely.  (TelephonyManager) helps tasker recognize the object as a such.  (See "casting" in the user guide.)

In a second task, select the telephony manager "myobj", which you have just created, under the coffee cup.  As Function, select getAllCellInfo{List}().  Because (), there is no Param.  Return the list object as a java object (choose a name without %), or as a tasker array (name starts with %).  You can now use the result in subsequent tasks.  (I use a javascriptlet to process the result.)

More information : http://developer.android.com/reference/android/telephony/package-summary.html

Op maandag 22 december 2014 12:03:46 UTC+1 schreef Nick77:

Nick77

unread,
Dec 22, 2014, 3:39:09 PM12/22/14
to tas...@googlegroups.com
Thanks a lot. I'll give it a try

Pent

unread,
Dec 23, 2014, 4:00:28 AM12/23/14
to tas...@googlegroups.com
>%), or as a tasker array (name starts with %).  You can now use the result in subsequent tasks.  (I use a javascriptlet to

Isn't that cool, mixing 2 languages (3 if you include Tasker actions) on the fly :-)

Pent

Dirk DP

unread,
Dec 23, 2014, 3:47:54 PM12/23/14
to tas...@googlegroups.com
Indeed.  That's why we heart Tasker !  (For stuff like complex string manipulation, loops and conditions, I find that javascript is just cleaner looking than native tasker actions.  In other aspects Javascript is more powerful, e.g. the Date object.)

Looking forward to the possible change you had in mind.  Meanwhile I have my homegrown Cell Near "in production" !  Works very well.  The only downside is that after scanning for towers, I have some manual work to turn the numbers into a suitable regex format.

Pent

unread,
Dec 29, 2014, 10:00:30 AM12/29/14
to tas...@googlegroups.com
I put out a prerelease of the next Tasker version (see top of forum), could you give it a test with the Cell Near state and the
New Cell API option ?

Thanks,

Pent

Dirk DP

unread,
Dec 29, 2014, 10:07:19 AM12/29/14
to tas...@googlegroups.com
4.6u2, so not 4.6u2m right ? (don't know the difference.)

Op maandag 29 december 2014 16:00:30 UTC+1 schreef Pent:

Dirk DP

unread,
Dec 29, 2014, 10:52:10 AM12/29/14
to tas...@googlegroups.com
Never mind.
I've just tested it. Happy to report that it works fine ! Updates do get through now.
(Not using the 'cell workaround' btw)
I'm keeping the pre release! My own java based solution goes out the window...

Pent

unread,
Dec 29, 2014, 11:54:05 AM12/29/14
to tas...@googlegroups.com
Well that's good news, I have to thank you for the tip.

Pent

ahamed nazumudeen

unread,
Jan 18, 2015, 6:17:24 AM1/18/15
to tas...@googlegroups.com
Help me!!
I have done the above two set of tasks with my tasker.
But I don't know, how to use that values in variable.
I had tried to flash the vales with the variable called %ownobj that, I named for return list at the last step.
But there wasn't show the tower IDs
Regards

Nick77

unread,
Jan 19, 2015, 5:31:43 PM1/19/15
to tas...@googlegroups.com
I'm trying to arrange a task following the suggestions but I can't return any value from it.. ..

Test Java Cell (24)
A1: Java Function [ Return:(TelephonyManager) cellnearobj Class Or Object:CONTEXT Function:getSystemService
{Object} (String) Param:phone Param: Param: Param: Param: ]
A2: Java Function [ Return:%cellnear Class Or Object:cellnearobj Function:getAllCellInfo
{List} () Param: Param: Param: Param: Param: ]
A3: Flash [ Text:%cellnear() Long:Off ]


Where do I go wrong?

Mad Mooney

unread,
Jan 20, 2015, 10:41:22 AM1/20/15
to tas...@googlegroups.com
I ran into similar problems.

Official documentation says that getAllCellInfo ()

...returns List of CellInfo or null if info unavailable.
...is preferred over using getCellLocation although for older devices thi
s may return null in which case getCellLocation should be called.

Although, I have to add that on my Lenovo here, both return the same.
Try the other one, then :-)

ahamed nazumudeen

unread,
Jan 20, 2015, 10:49:59 AM1/20/15
to tas...@googlegroups.com

I don't know java.
Wait, may anyone will help us. I.a

--
You received this message because you are subscribed to a topic in the Google Groups "Tasker" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/tasker/GGevuRth3ZY/unsubscribe.
To unsubscribe from this group and all its topics, send an email to tasker+un...@googlegroups.com.
Visit this group at http://groups.google.com/group/tasker.
For more options, visit https://groups.google.com/d/optout.

Odysseos

unread,
Jan 20, 2015, 2:45:50 PM1/20/15
to tas...@googlegroups.com
You just have to do the following : In the second Java Function (as in the above decription) use the getCellLocation instead of getAllCellinfo.In the return field put a tasker variable name (e.g. %cells) and then add a Flash action with %cells in the text field. This will flash to you the cell info.

Nick77

unread,
Jan 20, 2015, 3:39:05 PM1/20/15
to tas...@googlegroups.com
..even with getCellLocation unfortunately always getting "null" on my device ..
Thanks Samsung ;)

Ludovico D'Argenio

unread,
Jan 20, 2015, 4:56:41 PM1/20/15
to tas...@googlegroups.com

I too have a Samsung device (Galaxy S5). With getCellLocation I'm able to obtain the cell info. If you paste here your task I will try to help you...

Il 20/Gen/2015 21:39 "Nick77" <niccolo...@gmail.com> ha scritto:
..even with getCellLocation unfortunately always getting "null" on my device ..
Thanks Samsung ;)

Nick77

unread,
Jan 20, 2015, 5:11:10 PM1/20/15
to tas...@googlegroups.com
Basically same as the above plus getCellLocation

Test Java Cell (24)
A1: Java Function [ Return:(TelephonyManager) cellnearobj Class Or Object:CONTEXT Function:getSystemService
{Object} (String) Param:phone Param: Param: Param: Param: ]
A2: Java Function [ Return:%cellnear Class Or Object:cellnearobj Function:getCellLocation
{CellLocation} () Param: Param: Param: Param: Param: ]
A3: Flash [ Text:%cellnear() Long:Off ]


See anything wrong?
Thks

Nick77

unread,
Jan 20, 2015, 5:50:07 PM1/20/15
to tas...@googlegroups.com
..I was thinking to do a couple of tests with the "new cell API" option under prefs.. but can't find it. .where's it?
Is it "cell workaround" the same thing with a different name?

ahamed nazumudeen

unread,
Jan 20, 2015, 7:12:08 PM1/20/15
to tas...@googlegroups.com

Thank you so much.
Now flashing is works.
Is any way to get the all nearby cell tower IDs instead of normal profile's context method ?
That means use the JavaScript I.a
And one more thanks to you:-)

Odysseos

unread,
Jan 21, 2015, 1:04:40 AM1/21/15
to tas...@googlegroups.com
You must have {List} instead of {CellLocation}.

Nick77

unread,
Jan 21, 2015, 4:25:54 AM1/21/15
to tas...@googlegroups.com
Done that, but %cellnear is still empty..

do you know where can i find "new cell api" under prefs/monitor ?
i only see "cell workaround" and "net/cell wake screen" 
 

Nick77

unread,
Jan 21, 2015, 6:33:02 AM1/21/15
to tas...@googlegroups.com
do you know where can i find "new cell api" under prefs/monitor ?
i only see "cell workaround" and "net/cell wake screen" 
 


searching this forum i've just read that the "new Cell API" option needs android 4.2 to show up. 
that's why i can't see it ....

Ludovico D'Argenio

unread,
Jan 21, 2015, 6:48:35 AM1/21/15
to tas...@googlegroups.com

You can find new cell api here in Tasker Prrferences ( see the pic below)

--
Screenshot_21-01-2015_12.44-40.png

ahamed nazumudeen

unread,
Jan 21, 2015, 7:22:03 AM1/21/15
to tas...@googlegroups.com

That wasn't work
I wanna do the cell near operation that are doing by "state" profile as my own codes. Not by the regular profile method. That will be in the form of java functions or in basic gasket actions
Can you give the step by step procedures?
:-)

--

Nick77

unread,
Jan 22, 2015, 6:28:52 AM1/22/15
to tas...@googlegroups.com
thanks Odysseos  but , as i don't have android 4.2 , that option is not there for me

Reply all
Reply to author
Forward
0 new messages