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
Developer
mohitsharma
Posts: 190
Registered: ‎10-22-2009
My Device: Blackberry Torch
Accepted Solution

different icon for different entry point

Hi all,

 

In task switch bar i want to show different icon for application launched through different entry point.

any directions on this?

 

Thanks

-----------------------------------------------------------------------------------
Please mark posts as solved if you found a solution. Press the kudos button to thank the user who helped you.
Developer
Developer
CMY
Posts: 1,123
Registered: ‎02-10-2009
My Device: 8130 / 8350 / 9530 / 9550 / 9850 / PlayBook

Re: different icon for different entry point

Does your alternate entry start a UiApplication? If so, you should be able to set a different icon in the project properties. If not then I would set the alternate entry as the default icon and when the app is manually started change the icon accordingly.

Developer
mohitsharma
Posts: 190
Registered: ‎10-22-2009
My Device: Blackberry Torch

Re: different icon for different entry point

I am invoking alternate entry point programmatically modifying args in application descriptor and then invoking it using ApplicationManager.run(applicationDescriptor).

Problem with this approach is that its using the same icon as of old application in task switcher, i want to make it different from existing application.

Any ideas guys how can this be achieved.

-----------------------------------------------------------------------------------
Please mark posts as solved if you found a solution. Press the kudos button to thank the user who helped you.
Developer
peter_strange
Posts: 19,610
Registered: ‎07-14-2008
My Device: Not Specified

Re: different icon for different entry point

I've tried two ways, both using HomeScreen.updateIcon(...).

 

1) Before I start the new Application, I create the ApplicatinDescriptor, and after launching, I use the

updateIcon(icon.Application Descriptor)

method

 

2) When the new Application is started, I use the

udpateIcon(newIcon);

method.

 

In both cases, this changes the icon in the Task Switcher.  However it also changes the icon associated with the Base Application.

 

Can you try either or both of these methods and tell us if you see the same problem.

Developer
mohitsharma
Posts: 190
Registered: ‎10-22-2009
My Device: Blackberry Torch

Re: different icon for different entry point

yes peter i already tried that method and face the same problem both methods are changing icons but also of base application in task switcher.Which i wanted to be different.

 

I dont know why first method is not working eventhough its taking application descriptor as argument with args inside it modified.

-----------------------------------------------------------------------------------
Please mark posts as solved if you found a solution. Press the kudos button to thank the user who helped you.
Developer
mohitsharma
Posts: 190
Registered: ‎10-22-2009
My Device: Blackberry Torch

Re: different icon for different entry point

Just to be clear,

both methods above are changing icon for both the base app in task switcher and homescreen and for the other entry point.

What i want is to just change the icon of the other entry point app in task switcher.

Let me know if you have any thoughts over this.

-----------------------------------------------------------------------------------
Please mark posts as solved if you found a solution. Press the kudos button to thank the user who helped you.
Developer
peter_strange
Posts: 19,610
Registered: ‎07-14-2008
My Device: Not Specified

Re: different icon for different entry point

[ Edited ]

I think I'm going to report this to RIM.  Trouble is, my app is huge and pulling that bit out will be a problem.  Can you create a simple example that demonstrates this problem with no extra stuff for RIM to wade through?

Developer
mohitsharma
Posts: 190
Registered: ‎10-22-2009
My Device: Blackberry Torch

Re: different icon for different entry point

I will try to post it soon a small app/code or so illustrating the issue.

-----------------------------------------------------------------------------------
Please mark posts as solved if you found a solution. Press the kudos button to thank the user who helped you.
Developer
mohitsharma
Posts: 190
Registered: ‎10-22-2009
My Device: Blackberry Torch

Re: different icon for different entry point

Hi Peter,

I have pulled out some of basic stuff in code as follow:

 

//EntryPoint.java
import net.rim.device.api.ui.UiApplication;

public class EntryPoint extends UiApplication {
	
	public static void main(String[] args) {
		if (args != null && args.length > 0) {
			EntryPoint app = new EntryPoint(args);
			app.enterEventDispatcher();
		} else {
			System.exit(0);
			return;
		}
	}
	
	public EntryPoint(String[] args) {
		if (args != null && args.length > 0) {
			if (args[0].equals("ONE")) {
				pushScreen(new EntryPointOneScreen());
			} else if (args[0].equals("TWO")) {
				pushScreen(new EntryPointTwoScreen());
			}
		}
	}
	
}

 

 I am trying to launch the other entry point and changing their icon in menu item of screens EntryPointOneScreen and EntryPointTwoScreen.

 

 

 

//EntryPointOneScreen.java
import net.rim.device.api.system.ApplicationDescriptor;
import net.rim.device.api.system.ApplicationManager;
import net.rim.device.api.system.ApplicationManagerException;
import net.rim.device.api.system.Bitmap;
import net.rim.device.api.ui.MenuItem;
import net.rim.device.api.ui.component.Dialog;
import net.rim.device.api.ui.component.LabelField;
import net.rim.device.api.ui.component.Menu;
import net.rim.device.api.ui.container.MainScreen;



public class EntryPointOneScreen extends MainScreen {
	
	private LabelField lb;
	private ApplicationDescriptor currentAppDesc;
	private ApplicationManager appMgr;
	private Bitmap secondIcon;
	
	public EntryPointOneScreen() {
		super(DEFAULT_CLOSE|DEFAULT_MENU);
			
		lb = new LabelField("ENTRY POINT ONE");
		currentAppDesc = ApplicationDescriptor.currentApplicationDescriptor();
		appMgr = ApplicationManager.getApplicationManager();
		secondIcon = Bitmap.getBitmapResource("secondEntrypoint.png");
		
		add(lb);
	}
	
	private MenuItem secondPointItem =  new MenuItem("Second Entry", 2, 2) {
		public void run() {
			String args[] = {"TWO"};
			ApplicationDescriptor newAppDes = new ApplicationDescriptor(currentAppDesc, "EntryPointTwo", args);
			if (appMgr.getProcessId(newAppDes) != -1) {
				appMgr.requestForeground(appMgr.getProcessId(newAppDes));
			} else {
				try {
					appMgr.runApplication(newAppDes);
					net.rim.blackberry.api.homescreen.HomeScreen.updateIcon(secondIcon, newAppDes);
				} catch (ApplicationManagerException e) {
					Dialog.alert("second point not started :)");
				}
			}
		}
	};
	
	protected void makeMenu(Menu menu, int instance) {
		super.makeMenu(menu, instance);
		menu.add(secondPointItem);
		menu.add(MenuItem.separator(2));
	}
	
	
}

 

//EntryPointTwoScreen.java
import net.rim.device.api.system.ApplicationDescriptor;
import net.rim.device.api.system.ApplicationManager;
import net.rim.device.api.system.ApplicationManagerException;
import net.rim.device.api.system.Bitmap;
import net.rim.device.api.ui.MenuItem;
import net.rim.device.api.ui.component.Dialog;
import net.rim.device.api.ui.component.LabelField;
import net.rim.device.api.ui.component.Menu;
import net.rim.device.api.ui.container.MainScreen;



public class EntryPointTwoScreen extends MainScreen {
	
	private LabelField lb;
	private ApplicationDescriptor currentAppDesc;
	private ApplicationManager appMgr;
	private Bitmap firstIcon;
	
	public EntryPointTwoScreen() {
		super(DEFAULT_CLOSE|DEFAULT_MENU);
			
		lb = new LabelField("ENTRY POINT TWO");
		currentAppDesc = ApplicationDescriptor.currentApplicationDescriptor();
		appMgr = ApplicationManager.getApplicationManager();
		firstIcon = Bitmap.getBitmapResource("firstEntrypoint.png");
		
		add(lb);
	}
	
	private MenuItem firstPointItem =  new MenuItem("First Entry", 2, 2) {
		public void run() {
			String args[] = {"ONE"};
			ApplicationDescriptor newAppDes = new ApplicationDescriptor(currentAppDesc, "EntryPointOne", args);
			if (appMgr.getProcessId(newAppDes) != -1) {
				appMgr.requestForeground(appMgr.getProcessId(newAppDes));
			} else {
				try {
					appMgr.runApplication(newAppDes);
					net.rim.blackberry.api.homescreen.HomeScreen.updateIcon(firstIcon, newAppDes);
				} catch (ApplicationManagerException e) {
					Dialog.alert("first point not started :)");
				}
			}
		}
	};
	
	protected void makeMenu(Menu menu, int instance) {
		super.makeMenu(menu, instance);
		menu.add(firstPointItem);
		menu.add(MenuItem.separator(2));
	}
	
}

 

 

 

Update the thread when u get some update from RIM regarding this.

Thanks.

 

EntryPointOneScreen
-----------------------------------------------------------------------------------
Please mark posts as solved if you found a solution. Press the kudos button to thank the user who helped you.
Developer
mohitsharma
Posts: 190
Registered: ‎10-22-2009
My Device: Blackberry Torch

Re: different icon for different entry point

Hi,

I have found a workaround for my problem.

You can get the application descriptor for the entry points added in workspace then using CodeModuleManager you can get the application descriptors for the entry points for a given module.

By parsing this array of entry points for a module you can find out which you want to use and then use this index of entrypoint in homescrren.updateicon to change the icon.

 

 

ApplicationDescriptor[] apDes = CodeModuleManager.getApplicationDescriptors(CodeModuleManager.getModuleHandle("XXXXX"));

//apDes[0] is the default entry point
//apDes[1] is the first alternate entry point
//apDes[2] is the second alternate entry point
HomeScreen.updateIcon(icon, 1); // updateicon for first alternate entry point

 

Thanks.

 

-----------------------------------------------------------------------------------
Please mark posts as solved if you found a solution. Press the kudos button to thank the user who helped you.