Welcome to the Official BlackBerry® Support Community Forums. This is your resource to discuss support topics with your peers, and learn from each other. New to the forum? Please visit the ‘Getting Started’ link below.
inside custom component

Java Development

Reply
Regular Contributor
jkoorts
Posts: 63
Registered: 03-18-2009
Accepted Solution

Nasty one. How do I change the icon of my homescreen of my GUI app from an alternative startup point

Hi,

 

So, I have 1 app, 2 startup points. 1 point runs in the background on device startup, and has no icon or gui this point listens for BlackBerry push notifications. Point 2 is the GUI side of my app and is not running in this case. Point 1 now receives a push message and wants to update the icon of my app in point 2. 

 

Point 1 does not have an icon so net.rim.blackberry.api.homescreen.HomeScreen.setNewState(true) wont work!

Point 1 has to somehow get the icon of point 2 and update that.

 

How then?

Please use plain text.
Regular Contributor
jkoorts
Posts: 63
Registered: 03-18-2009

Re: Nasty one. How do I change the icon of my homescreen of my GUI app from an alternative startup point

So far I fixed it doing a nasty hack. point 1 saves icon update info into a RuntimeStore, starts point 2. Point 2 starts and see if there were new instructions, updates the icon and exits.

Please use plain text.
Developer
simon_hain
Posts: 10,780
Registered: 07-29-2008
My Carrier: O2 Germany

Re: Nasty one. How do I change the icon of my homescreen of my GUI app from an alternative startup point

http://www.blackberry.com/developers/docs/7.0.0api/net/rim/blackberry/api/homescreen/HomeScreen.html... int) should work, with the index of your gui app. most of the time some experimenting helps there.
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.

peter_strange wrote:
"This process should happen traumatically for you in both JDE and Eclipse."
Please use plain text.
Regular Contributor
jkoorts
Posts: 63
Registered: 03-18-2009

Re: Nasty one. How do I change the icon of my homescreen of my GUI app from an alternative startup point

Yeah but I want to use setNewState(boolean, descriptor), show I can get that nice and shiny BlackBerry star on my icon, but for the life of me I can't get the descriptor of the other starting point.

 

I'll mark as resolved, cause I'll use your method if I dont get sorted. Thanks

 

Please use plain text.
Regular Contributor
jkoorts
Posts: 63
Registered: 03-18-2009

Re: Nasty one. How do I change the icon of my homescreen of my GUI app from an alternative startup point

Got it!

 

String moduleName = "point2";
int handle = CodeModuleManager.getModuleHandle(moduleName);
ApplicationDescriptor[] descriptors = CodeModuleManager.getApplicationDescriptors(handle);
net.rim.blackberry.api.homescreen.HomeScreen.setNewState(true, descriptors[0]);

Please use plain text.
Regular Contributor
jkoorts
Posts: 63
Registered: 03-18-2009

Re: Nasty one. How do I change the icon of my homescreen of my GUI app from an alternative startup point

Actually the full correct code is here for anyone to use:

 

public static void setIndicator(int count) {
if (count == 0) {
Indicator.clearIndicator();
} else {
try {
try {
//#ifdef BlackBerrySDK4.6.0
HomeScreen.setName("MyApp (" + count + ")", 0);
//#else
ApplicationDescriptor descriptors = getGUIDescriptor();
if (descriptors != null) {
HomeScreen.setName("MyApp (" + count + ")", descriptors); 

}
//#endif

//#ifdef BlackBerrySDK6.0.0 || BlackBerrySDK7.0.0
ApplicationDescriptor descriptors67 = getGUIDescriptor();
if (descriptors67 != null) {
HomeScreen.setNewState(true, descriptors67);
}
//#endif
//#ifdef BlackBerrySDK4.7.0 || BlackBerrySDK5.0.0
ApplicationDescriptor descriptors47 = getGUIDescriptor();
if (descriptors47 != null) {
HomeScreen.updateIcon(iconNew, descriptors47);
}
//#endif
//#ifdef BlackBerrySDK4.6.0
HomeScreen.updateIcon(iconNew, 0);
//#endif
} catch (Exception e) {
Log.write("updateUnreadIndicators.2.1: " + e.toString());
}
try {
ApplicationIndicatorRegistry registry = ApplicationIndicatorRegistry.getInstance();
ApplicationIndicator indicator = registry.getApplicationIndicator();
if (indicator == null) {
indicator = registry.register(new ApplicationIcon(indicatoricon24), false, true);
}
indicator.setValue(count);
indicator.setVisible(true);
} catch (Exception e) {
Log.write("updateUnreadIndicators.2.2: " + e.toString());
}
} catch (Exception e) {
Log.write("updateUnreadIndicators.2.3: " + e.toString());
}
}
}

public static void clearIndicator() {
try {
try {
//#ifdef BlackBerrySDK4.6.0
HomeScreen.setName("MXit", 0);
//#else
ApplicationDescriptor descriptors460 = getGUIDescriptor();
if (descriptors460 != null) {
HomeScreen.setName("MXit", descriptors460);
}
//#endif
//#ifdef BlackBerrySDK6.0.0 || BlackBerrySDK7.0.0
ApplicationDescriptor descriptors67 = getGUIDescriptor();
if (descriptors67 != null) {
HomeScreen.setNewState(false, descriptors67);
}
//#endif
//#ifdef BlackBerrySDK4.6.0
HomeScreen.updateIcon(icon, 0);
//#endif
//#ifdef BlackBerrySDK4.7.0 || BlackBerrySDK5.0.0
ApplicationDescriptor descriptors47 = getGUIDescriptor();
if (descriptors47 != null) {
HomeScreen.updateIcon(icon, descriptors47);
}
//#endif
} catch (Exception e) {
Log.write("updateUnreadIndicators.1.1: " + e.toString());
}
ApplicationIndicatorRegistry registry = ApplicationIndicatorRegistry.getInstance();
try {
ApplicationIndicator indicator = registry.getApplicationIndicator();
if (indicator != null) {
indicator.setVisible(false);
}
} catch (Exception e) {
Log.write("updateUnreadIndicators.1.2: " + e.toString());
}
try {
registry.unregister();
} catch (Exception e) {
Log.write("updateUnreadIndicators.1.3: " + e.toString());
}
} catch (Exception e) {

}
}

private static ApplicationDescriptor getGUIDescriptor() {
ApplicationDescriptor[] descriptors = null;
int handle = CodeModuleManager.getModuleHandle("myapp");
if (handle > 0) {
descriptors = CodeModuleManager.getApplicationDescriptors(handle);
} else {
handle = CodeModuleManager.getModuleHandle("MyApp");
descriptors = CodeModuleManager.getApplicationDescriptors(handle);
}

if (descriptors != null && descriptors.length > 0) {
for (int i = 0; i < descriptors.length; i++) {
if (descriptors[i].getArgs() == null || descriptors[i].getArgs().length == 0) {
return descriptors[i];
}
}
}
return null;
}

Please use plain text.