10-25-2011 08:16 AM
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.se
Point 1 has to somehow get the icon of point 2 and update that.
How then?
Solved! Go to Solution.
10-25-2011 09:27 AM
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.
10-25-2011 10:46 AM
10-26-2011 02:36 AM
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
10-26-2011 02:48 AM
Got it!
String moduleName = "point2";
int handle = CodeModuleManager.getModuleHandle(moduleName);
ApplicationDescriptor[] descriptors = CodeModuleManager.getApplicationDescriptors(handle
net.rim.blackberry.api.homescreen.HomeScreen.setNe
10-28-2011 09:43 AM
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;
}