var app = require("application");

// .simple(View page, string snackText) is the simplest method available to construct a native snackbar
exports.simple = function (page, snackText) {

    if (page.android && snackText) {

        // Create the native snackbar
        var snackbar = android.support.design.widget.Snackbar;
        // Now call the snackbar .make() and .show() methods
        snackbar.make(page.android, snackText, 3000)
                .show();
    }

};

// exports.actionSnackbar = function(page, snackText, hideDelay, actionText, actionClickFunction) {
exports.action = function (options) {
        try {
            // Just making sure we are on Android for the native approach
            // Will see about integrating a cocoapod for iOS version
            if (app.android) {

                // Make sure user sent actionText and actionClickFunction
                // if undefined then we will pass the page, snackText arguments to the simple() method.
                if (!options.actionText || !options.actionClickFunction) {
                    console.log("No actionText or actionClickFunction sent in the options. Falling back to .simple() method");
                    exports.simple(options.page, options.snackText);
                } else {

                    // Create the OnClickListener for the Action of the Snackbar
                    var listener;
                    if (options.actionClickFunction) {
                        listener = new android.view.View.OnClickListener({
                            onClick: options.actionClickFunction
                        });
                    }

                    // Check for hideDelay - required
                    if (!options.hideDelay) {
                        options.hideDelay = 3000;
                    }

                    // Create the native snackbar
                    var snackbar = android.support.design.widget.Snackbar;

                    // Use the .make(), .setAction() methods to add text and functionality to the snackbar.
                    snackbar.make(options.page.android, options.snackText, options.hideDelay)
                                               .setAction(options.actionText, listener)
                                               .show();

                };

            };
        } catch (ex) {
            console.log(ex);
        }

};

@@ -26,16 +26,49 @@
 ation%22);
+%0Avar frame = require('ui/frame');
 %0A%0A// .si
@@ -76,19 +76,8 @@
 ple(
-View page, 
 stri
@@ -181,22 +181,16 @@
 nction (
-page, 
 snackTex
@@ -203,20 +203,19 @@
     if (
-page
+app
 .android
@@ -227,25 +227,24 @@
 nackText) %7B%0A
-%0A
         // C
@@ -415,17 +415,40 @@
 ar.make(
-p
+frame.topmost().currentP
 age.andr
@@ -495,24 +495,54 @@
 how();%0A    %7D
+ else %7B%0A        return;%0A    %7D;
 %0A%0A%7D;%0A%0A// exp
@@ -572,22 +572,16 @@
 unction(
-page, 
 snackTex
@@ -987,14 +987,8 @@
  the
- page,
  sna
@@ -1002,17 +1002,16 @@
 argument
-s
  to the 
@@ -1268,22 +1268,8 @@
 ple(
-options.page, 
 opti
@@ -2116,17 +2116,32 @@
 ake(
-options.p
+frame.topmost().currentP
 age.

Update index.js