Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
Contributor
Posts: 41
Registered: ‎11-11-2010
My Device: Not Specified
Accepted Solution

ApplicationMessageFolderRegistry registerFolder IllegalArgumentException

I have the same visual problem as described in this solved post, however my way of getting there is slightly different I think. To explain, I am trying to register a message folder for the purpose of issuing alerts/notifications on certain events. My applicaion is, technically, neither an Application nor a UIApplication - it is a top level class that then goes onto create one or the other depending on the entry point. So my background monitor AEP is an Application and my UI AEP is a UIApplication. In other words the main function is not in a class of either type.

 

I need to create a folder for the application into which the background monitor AEP can send messages. The folder should be registered with the UI AEP so that this is what opens when the folder is tapped on the home screen. I get the IllegalArgumentException when calling ApplicationMessageFolderRegistry.registerFolder and I believe this is because my main app is not strictly speaking a UIApplication.

 

Can anyone confirm this is the expected exception in this situation and what I might be able to do about it please? It's going to be tricky to redesign my app at this stage... I'd love there to be another solution. Below is the code that generates the exception. What's strange is that sometimes it seems to work ok, but sometimes it doesn't work and I then get two application icons in the notification bar.

 

ApplicationDescriptor uiAppDesc = null;

int moduleHandle = CodeModuleManager.getModuleHandle("my_app_module_name");
ApplicationDescriptor des[] = CodeModuleManager.getApplicationDescriptors(moduleHandle);
for (int i = 0; i < des.length; i++)
{
	String descName = des[i].getName();
	if (descName.equals("UI AEP Name"))
	{
		uiAppDesc = des[i];
	}
}

if (uiAppDesc == null)
{
	Debug.Log("Could not find ApplicationDescriptor for UI App entry point", Debug.DBG_NOTIFICATIONS);
	return;
}

ApplicationFolderIntegrationConfig config = new   ApplicationFolderIntegrationConfig( false, true, uiAppDesc);

//Register the ApplicationMessageFolder
//ReadableListImpl source is available in the messagelistdemo.
ApplicationMessageFolder folder = ApplicationMessageFolderRegistry.getInstance().getApplicationFolder(AppMain.APPLICATION_ID_LONG);
if (folder == null)
{
	folder = ApplicationMessageFolderRegistry.getInstance().registerFolder(
		AppMain.APPLICATION_ID_LONG, APPLICATION_MESSAGE_FOLDER_NAME, new ReadableListImpl(), config);
}

 

Contributor
Posts: 41
Registered: ‎11-11-2010
My Device: Not Specified

Re: ApplicationMessageFolderRegistry registerFolder IllegalArgumentException

It seems I've fixed this issue. The solution was to place the call to my code above inside a new Runnable with invokeLater. I was using a Runnable elswhere in the code, which is why the problem seemed to be intermittent.

 

Comparing the two code sections was the only way I stumbled across this fix. The document did not indicate this might cause an IllegalArgumentException to be thrown so I'm now wondering how I might have known this otherwise. I'm not sure *why* this fixed it for me... any further comments welcome!