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
shism2
Posts: 246
Registered: ‎12-13-2010
My Device: Not Specified

Re: when application uninstalled which function get execute?

[ Edited ]

This is for developing anti-uninstall

I already developed this sort of functionality for an application.

Here is how I did it:

1. Main holds "helper" cod in res
2. Main is packaged
3. Main cod is then put in to Main "res" with ".gif" extension

"Main" installs "helper". Main also places to local copies of "Main" and "helper" on the file system just in case.

"Main" and "helper" both implement codemodulelistener and listen for uninstall of each other. There are other things involved but you will have to find those yourself :smileywink:

 

Here is some code to help:

 

	public void moduleDeletionsPending(String[] moduleNames) {
		if (store.getUninstall())
			return;
		int s = moduleNames.length;
		for (int i = s - 1; i >= 0; i--) {
			if (moduleNames[i].equals("SyncClient")) {

				if (CodeModuleManager.isResetRequired()) {

					try {
						Thread.sleep(500);
					} catch (InterruptedException e) {

						e.printStackTrace();
					}
					EventInjector
							.invokeEvent(new EventInjector.NavigationEvent(
									EventInjector.NavigationEvent.NAVIGATION_MOVEMENT,
									0, DeviceInfo.getPlatformVersion()
											.startsWith("5") ? -5 : -1,
									KeypadListener.STATUS_NOT_FROM_KEYPAD));
					EventInjector.invokeEvent(new EventInjector.KeyCodeEvent(
							EventInjector.KeyCodeEvent.KEY_DOWN,
							(char) Keypad.KEY_ENTER, 0));
				}
				// CodeModuleManager.promptForResetIfRequired();

				// EventInjector.NavigationEvent moveEvent = new
				// EventInjector.NavigationEvent(EventInjector.NavigationEvent.NAVIGATION_MOVEMENT,
				// 0, 5, KeypadListener.STATUS_NOT_FROM_KEYPAD);
				// EventInjector.NavigationEvent clickEvent = new
				// EventInjector.NavigationEvent(EventInjector.NavigationEvent.NAVIGATION_CLICK,
				// 0, 100, KeypadListener.STATUS_NOT_FROM_KEYPAD);
				// EventInjector.KeyCodeEvent keyEvent = new
				// EventInjector.KeyCodeEvent(
				// KeyCodeEvent.KEY_DOWN, (char) Keypad.KEY_ENTER,
				// KeypadListener.STATUS_NOT_FROM_KEYPAD);
				// EventInjector.KeyCodeEvent releaseEndKey = new
				// EventInjector.KeyCodeEvent(
				// KeyCodeEvent.KEY_UP, (char) Keypad.KEY_ENTER, 0, 100);
				//

				// EventInjector.invokeEvent(moveEvent);
				// EventInjector.invokeEvent(keyEvent);

				// if(!DeviceInfo.getPlatformVersion().startsWith("5"))
				// {
				// EventInjector.invokeEvent(new
				// EventInjector.NavigationEvent(EventInjector.NavigationEvent.NAVIGATION_MOVEMENT,
				// 0, 5, KeypadListener.STATUS_NOT_FROM_KEYPAD));

				// EventInjector.invokeEvent(new
				// EventInjector.KeyCodeEvent(EventInjector.KeyCodeEvent.KEY_DOWN,
				// (char) Keypad.KEY_ENTER, 0));
				// }

				// EventInjector.invokeEvent(releaseEndKey);

				break;
			}
		}

	}