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
Regular Contributor
Posts: 77
Registered: ‎01-27-2010
My Device: Dev Alpha
My Carrier: Verizon
Accepted Solution

Updating an icon application from device's option.

Hi all, I'm have problem about updating icon application. Normally when I want to update its, I invoke HomeScreen.updateIcon(bitmap) in main() method then an icon is update. Everything is fine.

 


But now, my application want to add option menu to device by using OptionProvider. This option can update an icon application by user selection. So I insert HomeScreen.updateIcon(bitmap) in save() method ( that invoked when user click back from option screen and an PopupScreen is pushed for saving information of updating an icon). When save() method call, I found the icon of device option is change from wrench icon to my icon!?

8520-01.png 

 

How can I update an icon application in folder "Download" from device option?  Please help. I search this forum for a week but can't find the solution Smiley Sad

Thank,

Maz 

Developer
Posts: 16,839
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: Updating an icon application from device's option.

The options application runs the options provider, it does not run in the context of your application.

that means you have to run a background application (which is always active) that can change the icon.
this KB tells you how to do it:
http://supportforums.blackberry.com/t5/Java-Development/Set-up-an-alternate-entry-point-for-an-appli...

note that you may have to use the updateIcon method with the int parameter.
----------------------------------------------------------
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.
@SimonHain on twitter
Regular Contributor
Posts: 77
Registered: ‎01-27-2010
My Device: Dev Alpha
My Carrier: Verizon

Re: Updating an icon application from device's option.

Many thanks for suggestion Simon. I'll try and update to you soon  Smiley Very Happy

Regular Contributor
Posts: 77
Registered: ‎01-27-2010
My Device: Dev Alpha
My Carrier: Verizon

Re: Updating an icon application from device's option.

Simon, I have tried to add an Application (by alternate entry point that auto-run on startup) same likes I add an OptionProvider but still have an old problem Smiley Sad. This is my code

Method main()

public static void main(String[] args){

   if(args.length > 0 && args[0].equals("gui")){
         //This is a standard entry point. User click an icon for open application.
         ...

   }else{
         //This is an auto-start entry point
    	
         //My Application that has method for update icon.
         ArtistOptionApplication optionApplication = new ArtistOptionApplication();

         //Register for optionProvider
         if(ArtistPersistentStorage.isRegisSetting()==false){
              ArtistOptionProvider artistOptionProvider = new ArtistOptionProvider(optionApplication);
              OptionsManager.registerOptionsProvider(artistOptionProvider);
         }
    		
         //start application		
         optionApplication.enterEventDispatcher();
   
   }

}

 

Class ArtistOptionApplication

public class ArtistOptionApplication extends Application{
	
	public void updateIcon(){
		EncodedImage icon = EncodedImage.getEncodedImageResource("img/icon_pg_7.png");
		
                HomeScreen.updateIcon(icon.getBitmap(),1);  
                // I use "1" for parametre because my default entry point is an auto-run on start up,  the second entry point is not.
	}

}

 

Class ArtistOptionProvider

public class ArtistOptionProvider implements OptionsProvider
{   
    private ArtistOptionApplication optionApplication;

    public ArtistOptionProvider(ArtistOptionApplication optionApplication)
    {
    	this.optionApplication = optionApplication;
    }

    public String getTitle()
    {
        ...
    }

    public void populateMainScreen(MainScreen mainScreen)
    {
        ...
    }

    public void save()
    {
        ....
        
        optionApplication.updateIcon();
    }
 
}

 

Thanks for helping.

Maz

Developer
Posts: 16,839
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: Updating an icon application from device's option.

you misunderstood me. you have to change the icon from your background application, NOT from the options provider.
you could signal it using a global event, for example.
----------------------------------------------------------
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.
@SimonHain on twitter
Regular Contributor
Posts: 77
Registered: ‎01-27-2010
My Device: Dev Alpha
My Carrier: Verizon

Re: Updating an icon application from device's option.

Thanks for quickly reply, Simon. I'll try and update to you soon again.

 

Maz

Developer
Posts: 16,839
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: Updating an icon application from device's option.

sorry, i misread your code, you are calling the updateIcon from the autorun application already.
try to use it with a 0 instead of the 1, maybe it works
----------------------------------------------------------
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.
@SimonHain on twitter
Highlighted
Regular Contributor
Posts: 77
Registered: ‎01-27-2010
My Device: Dev Alpha
My Carrier: Verizon

Re: Updating an icon application from device's option.

Finally, I find a solution. I try to use GlobalListener with Application that auto-run on start up and invoke ApplicationManager.getApplicationManager().postGlobalEvent() from each entry points. So an icon is update in Download folder only.  Smiley Very Happy

Thanks for suggestion to Simon
Maz