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: 271
Registered: ‎12-24-2010
My Device: BlackBerry 10
My Carrier: Airtel
Accepted Solution

Checking the permissions is causing delay to launch the Application

Hi,

 

In my application, i am registering the Application with HttpFilter Registry. So if i will open any particular link, i will go the browser and again coming back to the application. Now for this i have created one entry point. And I am taking some permissions. Now the issue is, i am writing the permission in the Main method of the Application. So each time it is checking the permission and launching the app. So there is few seconds(5-6) delay in launching the application.   Here is the code for permissions:

 

 /** @return true if the user has accepted permissions requests */
    public static boolean hasPermissions() {
       ApplicationPermissionsManager apm = ApplicationPermissionsManager.getInstance();
       ApplicationPermissions original = apm.getApplicationPermissions();

       if(original.getPermission(ApplicationPermissions.PERMISSION_BROWSER_FILTER) == ApplicationPermissions.VALUE_ALLOW)
       {
          return true;
       } else {
          return false;
       } 
    }

    /** @return true if the user has accepted / granted permissions */
    public static boolean checkPermissions() {
       if (!hasPermissions()) {
          ApplicationPermissions permRequest = new ApplicationPermissions();
          permRequest.addPermission(ApplicationPermissions.PERMISSION_BROWSER_FILTER);
          return ApplicationPermissionsManager.getInstance().invokePermissionsRequest(permRequest);
       } else {
          return true;
       }
    }

 And here i am checking in the main method:

 

public static void main(String args[])
	{
		if(checkPermissions());
		{
			try {
				if((args != null) && (args.length > 0) && (args[0].equals("background")))
				{
					
					Logger.out("AppLaunch", "in the alternate entry point");
					HttpFilterRegistry.registerFilter("URL", "packagename");
				}
				else if(args != null)
				{
					Logger.out("AppLaunch", "Inside the Applaunch");
					theApp = new ArcotOtpApp(); 
					Logger.out("AppLaunch", "created the app launch object");
					theApp.enterEventDispatcher();
				}
			} catch (Exception e) {
				// TODO Auto-generated catch block
				Logger.out("AppLaunch", "Exception::::::11111111" +e);
			}
		}
		
	}

 Can any one please tell me where i am doing wrong or what is the correct way so that delay will not be there.

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

Re: Checking the permissions is causing delay to launch the Application

My experience is that permissions checking takes no time at all.  I suspect there is another issue that is delaying your app starting.  

 

Anyway to prove whether or not the permissions checking delaying your app, I would check the actual time in there.  Just do something like:

 

long startTime =System.currentTimeMillis();

// run permissions checking

long timeChecking =System.currentTimeMillis() - startTime;

System.out.println("Time for permissions = " + Long.toString(timeChecking));

 

Well you get the idea.

 

Let us know how long you find you actually spend checking.  Remember the time is in milliseconds, so divide by 1000 to get actual seconds. 

Developer
Posts: 271
Registered: ‎12-24-2010
My Device: BlackBerry 10
My Carrier: Airtel

Re: Checking the permissions is causing delay to launch the Application

Thanks a lot Peter. I check on your way. It was not the permission issue. There was some other object instantiations are happening while going to main Screen. Which are causing the launch slower.

 

Thanks again.

 

And can you help me on this issue also:  http://supportforums.blackberry.com/t5/Java-Development/Active-RichText-Field-Hyperlink-issue/td-p/2...