Getting app icon URL using tasker java functions and objects

476 views
Skip to first unread message

Yash Srivastav

unread,
Apr 18, 2015, 7:56:34 AM4/18/15
to tas...@googlegroups.com
How would I go about doing this : http://stackoverflow.com/questions/17985500/how-can-i-get-the-applications-icon-from-the-package-name

I need to display the obtained icon in a scene so I would also require the URL not just the drawable object

Thanks in advance.

I know java but I can't get the hang of using it in tasker

Saad Thahim

unread,
Apr 18, 2015, 10:06:15 AM4/18/15
to tas...@googlegroups.com
You want URL of what? 
You can use autonotifications plugin to get the statusbar icon from a notification.

Yash Srivastav

unread,
Apr 18, 2015, 10:27:26 AM4/18/15
to tas...@googlegroups.com
I want URL of the icon such that I might use it in a scene image .,..I wanted a free alternative plus I want the app icon

Robert Ryan

unread,
Apr 18, 2015, 12:34:06 PM4/18/15
to tas...@googlegroups.com
Get a PackageManager interface using getPackageManager() from Tasker's built-in CONTEXT object

getApplicationInfo() and getApplicationIcon() are both part of the PackageManager interface.

Yash Srivastav

unread,
Apr 18, 2015, 10:35:24 PM4/18/15
to tas...@googlegroups.com
Java (450)
A1: Java Function [ Return:pckmn Class Or Object:CONTEXT Function:getPackageManager
{PackageManager} () Param: Param: Param: Param: Param: Param: Param: ]
A2: Java Function [ Return:drwble Class Or Object:pckmn Function:getApplicationIcon
{Drawable} (ApplicationInfo) Param:"com.whatsapp" Param: Param: Param: Param: Param: Param: ]
A3: Java Function [ Return:steng Class Or Object:drwble Function:toString
{String} () Param: Param: Param: Param: Param: Param: Param: ]
A4: Flash [ Text:%steng Long:Off ]

I'm doing this but its showing error on A2

Robert Ryan

unread,
Apr 18, 2015, 11:09:35 PM4/18/15
to tas...@googlegroups.com


On April 18, 2015 8:35:24 PM MDT, Yash Srivastav <yash1...@gmail.com> wrote:
>I'm doing this but its showing error on A2

You need to call the getAppicationIcon() method of the PackageManager object
Then you use the returned ApplicationInfo object in your getApplicationIcon call.

You were trying to use the ApplicationInfo class there instead of an object.

HTH

Robert Ryan

unread,
Apr 18, 2015, 11:14:36 PM4/18/15
to tas...@googlegroups.com
Scratch that last sentence :-)

The rest should be correct.

Yash Srivastav

unread,
Apr 19, 2015, 2:46:11 AM4/19/15
to tas...@googlegroups.com
OK thanks I got the drawable object.. Now how would I go about displaying it in a scene (I need the drawable URL something like android.resource://com.Whatsapp/drawable/icon )

Richard Wallace

unread,
Apr 19, 2015, 6:04:12 AM4/19/15
to tas...@googlegroups.com
Could you share what you've already got?

Yash Srivastav

unread,
Apr 19, 2015, 7:46:45 AM4/19/15
to tas...@googlegroups.com
Java (450)
A1: Java Function [ Return:pckmn Class Or Object:CONTEXT Function:getPackageManager
{PackageManager} () Param: Param: Param: Param: Param: Param: Param: ]
A2: Java Function [ Return:drwble Class Or Object:pckmn Function:getApplicationIcon
{Drawable} (String) Param:"com.whatsapp" Param: Param: Param: Param: Param: Param: ]
A3: Java Function [ Return:bmap Class Or Object:(BitmapDrawable)drwble Function:getBitmap
{Bitmap} () Param: Param: Param: Param: Param: Param: Param: ]
A4: Java Function [ Return:%pict Class Or Object:bmap Function:toString
{String} () Param: Param: Param: Param: Param: Param: Param: ]
A5: Flash [ Text:%pict Long:Off ]


This task gives me the drawable and its bitmap but I can't figure out how to get the exact URL of the icon.


In scene edit..if u create an element image and set it as ->application icon->Whatsapp and then switch to formula mode u get the path to whatsapp's icon as :

android.resource://com.whatsapp/drawable/icon


I'm trying to obtain this path using java functions...if tasker can access it using java junctions then even I can...most probably pent would know how to obtain it...

Richard Wallace

unread,
Apr 19, 2015, 8:21:33 AM4/19/15
to tas...@googlegroups.com
Thanks.
I've got that working.
Biy every time I run it and flash the variable it changes?

Yash Srivastav

unread,
Apr 20, 2015, 1:53:10 AM4/20/15
to tas...@googlegroups.com
Java (450)
A1: Java Function [ Return:pckmn Class Or Object:CONTEXT Function:getPackageManager
{PackageManager} () Param: Param: Param: Param: Param: Param: Param: ]
A2: Java Function [ Return:appinf Class Or Object:pckmn Function:getApplicationInfo
{ApplicationInfo} (String, int) Param:"com.whatsapp" Param:0 Param: Param: Param: Param: Param: ]
A3: Java Function [ Return:%ancdef Class Or Object:appinf.icon Function:assign
{int} () Param: Param: Param: Param: Param: Param: Param: ]
A4: Variable Set [ Name:%Icurl To:android.resource://com.whatsapp/%ancdef Do Maths:Off Append:Off ]


I managed to do it like this.

Richard Wallace

unread,
Apr 20, 2015, 11:59:26 AM4/20/15
to tas...@googlegroups.com
Brilliant!
Works perfectly.
Been trying to do this for ages!
Teaming this with an AutoNotification intercept / Query i can now get any app icon into a scene!
Thank You!

Basem

unread,
Feb 21, 2019, 11:24:27 PM2/21/19
to Tasker
Hi ,
Can you please send me the tasks file,
I tried to do it manually but i always get errors.

Thanks in advance , I really appreciate it
Reply all
Reply to author
Forward
0 new messages