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
New Contributor
Posts: 5
Registered: ‎01-10-2011
My Device: Not Specified
Accepted Solution

Is it possible to use one application to register another application?

I have two applications. One is running in the background all the time, the other handles UI mostly, it may or may not be launched by the user. This UI application needs be initialized (such as being registered with the message folder) before it can be used.

 

I am trying to use the background application to register my UI application with the message folder, but I can not get it work. The code always throws an exception. Not sure what I did wrong, or simply it is not possible to do so.

 

Here is the snippet of the code.

 

 

// get the ui application descriptor
int handle = CodeModuleManager.getModuleHandle(“my_ui_application_name”);
ApplicationDescriptor[] apps = CodeModuleManager.getApplicationDescriptions(handle);
ApplicationDescriptor guiApp = new ApplicationDescriptor(app[0], “appName”, new String[] {“gui”});


// register the folder
ApplicationFolderIntegrationConfig config = new ApplicationFolderIntegrationConfig(false, true, guiApp)
ApplicationMessageFolderRegistry.getInstance().registerFolder(FOLDER_ID, guiApp.getName(), _list, config);

 The exception (illegal argument exception) occurred at the last line of the code. The following from the API doc of  ApplicationMessageFolderRegistry.

 

IllegalArgumentException - if folder ID is equal to 0 OR the folder with the same name or ID was already registered OR the folderName has 0 length

 

Can someone help me?

 

Developer
Posts: 604
Registered: ‎12-27-2010
My Device: Not Specified

Re: Is it possible to use one application to register another application?

Are they two actual separate applications, or just alternate entry points?

New Contributor
Posts: 5
Registered: ‎01-10-2011
My Device: Not Specified

Re: Is it possible to use one application to register another application?

They are two different apps. Thanks.
New Contributor
Posts: 5
Registered: ‎01-10-2011
My Device: Not Specified

Re: Is it possible to use one application to register another application?

The following code throws the same IllegalArgumentException, if guiApp is an ApplicationDescriptor from antoher app (*not* just an entry point of the same app).

 

 

ApplicationMessageFolderRegistry.getInstance().registerMessageMenuItems(MESSAGE_TYPE, ApplicationMessage.Status.UNOPENED, new ApplicationMenuItem[] {openMenuItem}, guiApp);

 

Can someone from RIM confirm that it is not possible to do so???

 

 

I read all the API docs, but could not find a clue whether the descriptor (to be registered) has to be from the same application.

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

Re: Is it possible to use one application to register another application?

[ Edited ]

I have the same issue here, except my app descriptor is for an alternative entry point of the same app. Can anyone explain why this is happening and how to fix the problem please?

 

My code gets the descriptors for my app from the CodeModuleManager and tries to find the UI AEP.

 

The code that generates this for me is as follows...illegal argument exception on last line.

 

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);
}

 

Thanks very much.

 

edit: I just realised this is a solved issue - I don't mind starting a new thread but this is my issue.

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

Re: Is it possible to use one application to register another application?

The docs say a UIApplication must be specified in the config, however my app main function is in a class that is neither type of Application, but it creates a UIApplication or Application object based on whether it is the main UI thread or background thread. Does this mean the method will always fail? It seems to work sometimes...