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: 367
Registered: ‎11-25-2009
My Device: Not Specified

NullPointerException on invokePermissionsRequest "Save"

Hello,

 

When my application starts, I will check the application permissions and invoke the permissions screen if they are not set to what is required for my application.  If the user selects to allow the permissions and then "Save", the application will continue.  Otherwise, the application will close.

 

When the user clicks "Save", however, the application throws a NullPointerException.  I can't debug this, but I'm guessing that it is happening on invokePermissionsRequest().  Has this happened to anyone before?  Does anyone have any recommendations on what to do here?  Please see my code below:

 

public static boolean changeLocationDataPermission() {

		boolean userResponse;

		ApplicationPermissions permissions = new ApplicationPermissions();
		permissions
				.addPermission(ApplicationPermissions.PERMISSION_LOCATION_DATA);
		permissions.addPermission(ApplicationPermissions.PERMISSION_PHONE);

		if (ApplicationPermissionsManager.getInstance()
				.invokePermissionsRequest(permissions)) {
			userResponse = true;
		} else {
			userResponse = false;
		}

		return userResponse;
	}

 

Developer
Posts: 655
Registered: ‎02-03-2010
My Device: Z10 LE
My Carrier: Rogers

Re: NullPointerException on invokePermissionsRequest "Save"

This code looks good.  I would guess that the null pointer is somewhere after this code.  The user hits Save and then your code continues.   You may want to use the event logger to help.  Add an event after this function is called to make sure it gets all the way through.   Have you tried looking in the event log to see where the NullPointer is happening?


Steven Kader at JaredCo
   Follow me on Twitter    |     Mipixi.com :  Web App for Photo Sharing
Developer
Posts: 367
Registered: ‎11-25-2009
My Device: Not Specified

Re: NullPointerException on invokePermissionsRequest "Save"

[ Edited ]

Hm,

 

I think that the location in which I am changing the permissions in my application is causing the NullPointerException.  In my main class, I have:

 

public static void main(String[] args) {
	MyApp theApp = new MyApp();
	theApp.enterEventDispatcher();
}

public MyApp() {
if (!PermissionManager.checkLocationDataPermission()) {
boolean userResponse = PermissionManager.changeLocationDataPermission();
if (userResponse) {
new SplashScreen();
} else {
System.exit(0);
}
} else {
new SplashScreen();
}
}

 However, if I run that code in my home screen (the screen that appears after SplashScreen), then I don't receive any NullPointerException.  Is the location where I am running the code a problem?