Friday, March 21, 2014

Debugging exported eclipse plugins

When working in eclipse plugin development one thing you come across often is the plugin runs as expected when debugging from the Plugin Project, but when you install the exported plugin things just don't work. Reasons for this could be anything as simple as not specifying external jar files in the 'Runtime' tab of the plugin.xml file to something as unexpected as a runtime exception. The easiest way to debug such issues is to launch eclipse with the console running.

Command to launch eclipse with console:

eclipse -debug builder.options

Now all plugin log messages and exception messages will be displayed in the console.

For more details on debugging eclipse plugins for the end user please see:

Cordova plugin to display image files full screen inside your iOS/Android app

A while ago I blogged about a customized HTML5 canvas/js implementation for full screen image display inside your cordova app. The advantage of this method was that it retained the application header and footer, however the drawback was that pinch zoom did not work well under device orientation changes. For anyone who doesn't want to deal with the complexities of a canvas based pinch zoom capable js solution a much simpler solution is to utilize iOS and Android native capabilities to launch the image in the default image viewer, from inside your application.


Inside a cordova plugin for ios implement the following call UIDocumentInteractionController.

        NSString *fullPath = @"specify file path here";
        NSURL *URL = [NSURL fileURLWithPath:fullPath];
        if (URL) {
            UIDocumentInteractionController *documentInteractionController = [UIDocumentInteractionController interactionControllerWithURL:URL];
             [documentInteractionController setDelegate:[[[UIApplication sharedApplication] keyWindow] rootViewController]];
            if (![documentInteractionController presentPreviewAnimated:YES])
                NSLog(@"Failed to open document in Document Directory");

Also let your cordova applications main view controller implement the UIDocumentInteractionControllerDelegate.


Inside a cordova plugin for android implement the following call to an intent

Intent intent = new Intent();
intent.setDataAndType(Uri.parse(filePath), "image/*");

You will need to implement threading to prevent the UI thread from hanging.

For details on setting up a Cordova plugin inside iOS/Android refer to