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
Posts: 144
Registered: ‎08-18-2012
My Device: Blackberry Curve 8520
My Carrier: Vodafone

How to show a message dialog when an app is installed?

Hello everyone. I want to show up a popup as soon as my application is installed. Actually, I'm setting permissions for my application. So, as soon as my application is installed, a popup comes to "View" permissions and save them. But the user can't know ho to do it. So, I want to popup a screen to tell him that he has to view permissions and save them. How can a popup be shown before the view permissions dialog pops up? I've tired some code but its not working anyways. Can anybody help? 
Thanks in advance. 

Developer
Posts: 19,636
Registered: ‎07-14-2008
My Device: Not Specified

Re: How to show a message dialog when an app is installed?

Just responding quickly from memory. 

 

The ApplicationPermissionsDemo sample show you how you can control when the Permissions Dialog is shown.  You just need to use code like that to check your permissions, then, if you do not have permissions, push a screen saying you are about to ask, and then ask. 

 

So rework that demo code to achieve what you want.

 

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

Re: How to show a message dialog when an app is installed?

you can use a http://www.blackberry.com/developers/docs/7.1.0api/net/rim/device/api/applicationcontrol/ReasonProvi... for this
----------------------------------------------------------
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
Developer
Posts: 144
Registered: ‎08-18-2012
My Device: Blackberry Curve 8520
My Carrier: Vodafone

Re: How to show a message dialog when an app is installed?

Hello Peter and Simon. Thanks for helping me again. I was using the code below as my application is a hidden one. 

 

UiApplication.getUiApplication().invokeLater(new Runnable()
        {
            public void run()
            {
            	Dialog.inform("View permissions, click on Menu the button and click on Save");
            }
        });

 

The dialog pops up but when I press the "OK" button the dialog doesn't close. Infact, the down arrow of the dialog also gets disabled. Can you tell me the reason for this and how can I get a workaround for this? Thanks again.

 

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

Re: How to show a message dialog when an app is installed?

what do you mean with "hidden"?
if you want an application without UI you better use Application instead of UiApplication, as the former "wants" a screen.
you can use Ui.getUiEngine to display a global screen from a non-ui app.
----------------------------------------------------------
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
Developer
Posts: 144
Registered: ‎08-18-2012
My Device: Blackberry Curve 8520
My Carrier: Vodafone

Re: How to show a message dialog when an app is installed?

By "Hidden" I mean that I have checked the "Do not display the application icon on Blackberry home screen" in the Blackberry Application Descriptor. My application asks the user to save some permissions when its installed. And what I need to do is, I want to popup a dialog box on the screen as soon as my application is installed, before the view permissions Dialog which pops up. I can't seem to do this with ApplicationPermissionsDemo. So, I used Dialog.inform(mymessage); before checking and saving the permissions for my application.

Now the dialog is displayed, but its shown after the view permissions dialog. Also, the main problem is that I'm not able to close the dialog box I'm displaying. What can be done for this. Thanks a lot.

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

Re: How to show a message dialog when an app is installed?

you can use a http://www.blackberry.com/developers/docs/7.1.0api/net/rim/device/api/applicationcontrol/ReasonProvi... to customize the permission request.

otherwise you would have to share the code, difficult to say what you are doing wrong without seeing it.
----------------------------------------------------------
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
Developer
Posts: 144
Registered: ‎08-18-2012
My Device: Blackberry Curve 8520
My Carrier: Vodafone

Re: How to show a message dialog when an app is installed?

Thanks for your help Simon. I think with ReasonProvider I'll be able to show the message whenever that permission is used in the application. But I want to show the message popup as soon as my application is installed.

My updated code so far is as below :

 

public class MyBackgroundApp extends Application implements SystemListener
{
 private MyBackgroundApp()
    {              	   	    	
    	try{
    		setPermissions();
    	}catch(Exception e){
            System.out.println("e3634: "+e.getMessage());
    	}    	    		
    	addSystemListener(this);     	
    }

private void setPermissions(){		
		new Thread(){
            public void run() {  
                    synchronized (getEventLock()) {
                        //with this UiEngine I'm able to pushGlobal dialogs                        
                        UiEngine ui = Ui.getUiEngine();
                        Screen screen = new Dialog(Dialog.D_OK, "View permissions, click on Menu button and Click on Save", Dialog.OK, Bitmap.getPredefinedBitmap(Bitmap.EXCLAMATION), Manager.VERTICAL_SCROLL);
                        ui.pushGlobalScreen(screen, 1, UiEngine.GLOBAL_QUEUE);
                    }                
            }
        }.start();

		 ApplicationPermissionsManager manager = ApplicationPermissionsManager.getInstance();			 
		 int current = manager.getPermission(ApplicationPermissions.PERMISSION_INPUT_SIMULATION);		 
		 if (current != ApplicationPermissions.VALUE_ALLOW) {
			 ApplicationPermissions permissions = new ApplicationPermissions();
			 permissions.addPermission(ApplicationPermissions.PERMISSION_INPUT_SIMULATION);
			 manager.invokePermissionsRequest(permissions);
		 } 		
	}
	
	//other methods
}

 

Now, what is happening is that my device hangs when I install my application. Everytime I have to uninstall my application with the Blackberry Desktop Software. It was not like this before (when I was just using the Dialog.inform() to show the message popup on screen). I really have no idea why. Can you check it please? Thank you again.

 

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

Re: How to show a message dialog when an app is installed?

and why are you using a thread? this causes the code to be executed at a later time (or concurrently) and would cause the dialog showing after the permission request.
you can show the dialog blocking before requesting permissions.
----------------------------------------------------------
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
Developer
Posts: 144
Registered: ‎08-18-2012
My Device: Blackberry Curve 8520
My Carrier: Vodafone

Re: How to show a message dialog when an app is installed?

[ Edited ]

I've updated my code:

 

private void setPermission(){	
Application.getApplication().invokeAndWait(new Runnable(){
            public void run() {                      
                        //with this UiEngine I'm able to pushGlobal dialogs                        
                        UiEngine ui = Ui.getUiEngine();
                        Screen screen = new Dialog(Dialog.D_OK, "View permissions, click on Menu button" +
                        " and Click on Save", Dialog.OK, Bitmap.getPredefinedBitmap(Bitmap.EXCLAMATION), Manager.VERTICAL_SCROLL);
                        ui.pushGlobalScreen(screen, 1, UiEngine.GLOBAL_QUEUE);
                    }
		});

ApplicationPermissionsManager manager = ApplicationPermissionsManager.getInstance();			 
		 int current = manager.getPermission(ApplicationPermissions.PERMISSION_INPUT_SIMULATION);		 
		 if (current != ApplicationPermissions.VALUE_ALLOW) {
			 ApplicationPermissions permissions = new ApplicationPermissions();
			 permissions.addPermission(ApplicationPermissions.PERMISSION_INPUT_SIMULATION);
			 manager.invokePermissionsRequest(permissions);
		 } 		
	}
	
	//other methods
}

 

But my device still hangs when I install my application. Thanks for your patience and your time.