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: 174
Registered: ‎01-25-2011
My Device: Not Specified

Using code module listener

HI all, I m trying to delete the files related to the app, when the app is uninstalled but i m not succesfull

Below is the code snippet, which is written in the uiapplication's class

		EventLogger.register(0xedd91885e3a618d8L, ApplicationDescriptor
				.currentApplicationDescriptor().getName(),
				EventLogger.VIEWER_STRING);
		CodeModuleListener cmListener = new CodeModuleListener() {

			public void modulesDeleted(String[] moduleNames) {
				EventLogger.logEvent(APP_ID, "In modulesDeleted".getBytes(),
						EventLogger.INFORMATION);
				deleteFile();
			}

			public void modulesAdded(int[] handles) {
				EventLogger.logEvent(APP_ID, "In modulesAdded".getBytes(),
						EventLogger.INFORMATION);
				deleteFile();
			}

			public void moduleDeletionsPending(String[] moduleNames) {
				EventLogger.logEvent(APP_ID,
						"In moduleDeletionsPending".getBytes(),
						EventLogger.INFORMATION);
				deleteFile();
			}
		};
		try {
			CodeModuleManager.addListener(UiApplication.getApplication(),
					cmListener);
		} catch (NullPointerException e) {
			EventLogger.logEvent(APP_ID,
					("In add listener exception" + e.getMessage()).getBytes(),
					EventLogger.ERROR);
			e.printStackTrace();
		}
		

	

 Also i m not able to find any logs related to the application....  Am i doing some thing wrong??

 

Thanks in advance!!

Developer
Posts: 16,495
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport

Re: Using code module listener

the problem is that your application is already deleted when the listener would be called.
there have been some threads about this problem, and you don't have many choices, one would be to have a second application cleaning up and uninstalling itself afterwards.
----------------------------------------------------------
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