简体   繁体   中英

Get Application Icon Image From Springboard (Jailbreak)

I'm developing a lockscreen application using theos and part of the functionality requires icon images of certain applications on the phone. How can I go about getting those icon images and displaying them on the lockscreen of the phone?

I've tried everything I could think of so far and have searched through the springboard headers with no luck. I've specifically been trying retrieving the images from SBApplication and SBIconModel from suggestions I found through google, but still I have no luck.

Any help is greatly appreciated. Thanks!

After you %hook a class, inside the method you're using, do the following if for example you're trying to get the icon for the mail app

// Get the SBApplication for the mail app
Class $SBApplicationController = objc_getClass("SBApplicationController");
SBApplication *mailApp = [[$SBApplicationController sharedInstance] applicationWithDisplayIdentifier:@"com.apple.mobilemail"];

// Get the SBApplicationIcon for the mail app
SBApplicationIcon *mailAppIcon = [[objc_getClass("SBApplicationIcon") alloc] initWithApplication:mailApp];

The important thing is to get the right DisplayIdentifier of the app you're interested in.

Hope this help! any problems please shout.

Although, I accept the above as the answer, I ended up using the following code, which displays titles and badges:

SBIcon *sbIcon = [model applicationIconForDisplayIdentifier:identifier];
SBIconView *app = [[%c(SBIconView) alloc] initWithDefaultSize];
[app setIcon:sbIcon];

//if you want the titles to be conditional
[app setLabelHidden:!titlesEnabled];

//if you want the badge view to be conditional
id badgeView;
if (device_version >= 6.0) badgeView = MSHookIvar<id>(app, "_accessoryView");
else badgeView = MSHookIvar<id>(app, "_badgeView");
if (badgeView) [badgeView setHidden:!badgesEnabled];

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM