How to get the icon of an installed application?

64 views
Skip to first unread message

Whitehap

unread,
Nov 13, 2019, 11:43:28 PM11/13/19
to DroidScript
How to get the icon of an installed application?

Steve Garman

unread,
Nov 17, 2019, 10:28:55 AM11/17/19
to androi...@googlegroups.com
I'm not sure exactly what you are looking for but if you know the package name of the app you are looking for you could try something like this.


Edit: Corrected version below

Steve Garman

unread,
Nov 17, 2019, 10:37:57 AM11/17/19
to androi...@googlegroups.com
I really shouldn't code in the browser. There were a couple of bugs in that code, img was local instead of global and I should have given the file an appropriate extension.
This has been tested although array.filter may need a shim to make it work on old versions of Android.

var appSought="com.smartphoneremote.androidscriptfree";
function OnStart()
{
lay = app.CreateLayout( "Linear", "fillxy" );
app.AddLayout( lay );
appList = app.GetActivities();
ret = appList.filter(function(a){
return(a.packageName==appSought);
});
a = ret[0];
img = app.CreateImage( a.packageName+"/"+a.className,512,-1,"Icon,px" );
lay.AddChild( img );

img.SetOnTouchUp( img_OnTouchUp );
}

function img_OnTouchUp()
{
img.Save( "/sdcard/thisIcon.png" );
app.ShowPopup( "Saved" );
}

Reply all
Reply to author
Forward
0 new messages