AccountManager.getAccounts() returns empty array. Help (Java Function)

348 views
Skip to first unread message

Alexandre Dumont

unread,
Jan 2, 2017, 10:31:31 AM1/2/17
to Tasker
I'm trying to get a list of all defined Account on the device, by using Java Function.

This is what I've done:

GetAccounts (91)

A1: Java Function [ Return:accmgr Class Or Object:AccountManager Function:get
{AccountManager} (Context) Param:CONTEXT Param: Param: Param: Param: Param: Param: ]

A2: Java Function [ Return:(Account[]) accounts Class Or Object:accmgr Function:getAccounts
{Account[]} () Param:1 Param: Param: Param: Param: Param: Param: ]

A3: Java Function [ Return:%accsize Class Or Object:Array Function:getLength
{int} (Object) Param:accounts Param: Param: Param: Param: Param: Param: ]

A4: Flash [ Text:%accsize Long:Off ]

I would expect it to return a non empty array of all the accounts, as the SDK says (I have multiple accounts defined on that device), but task A4 shows 0 in the toast. :(

Any idea why?

Alexandre Dumont

unread,
Jan 2, 2017, 10:46:39 AM1/2/17
to Tasker
Ok found the explanation myself... Tasker doesn't have the necessary permission (android.permission.GET_ACCOUNTS).

If I export the very same task as an App and give the extra permission "android.permission.GET_ACCOUNTS", it will then show a non 0 value.

That's a little bit unconvenient but at least I get the explanation :).

Pent

unread,
Jan 3, 2017, 5:53:13 AM1/3/17
to Tasker
Permissions like GET_ACCOUNTS tend to scare people, so since Tasker doesn't
need it, it's not requested.

Pent
Reply all
Reply to author
Forward
0 new messages