I’m trying to setup a file observer, but all I get is this error…

I’m trying to setup a file observer, but all I get is this error…

I don’t even know if we can have a fileobserver running in background with LL, but I’m trying.. 

TrianguloY​ Lukas Morawietz​ Pierre Hébert​

]]>

8 Commentsto I’m trying to setup a file observer, but all I get is this error…

  1. Anonymous says:

    < ![CDATA[

    LL.bindClass(“android.os.FileObserver”)



    function setupObserver(pathToWatch)


    {



    //ERROR IS HERE


    var observer = new FileObserver(pathToWatch) {



    // set up a file observer to watch this directory on sd card


    onEvent: function(eventMask, filePath) {



    if (eventMask == FileObserver.CREATE) {


    Android.makeNewToast(filePath + ” created”, true).show();


    } else {


    Android.makeNewToast(“event ” + eventMask + ” for file ” + filePath).show();


    }



    },



    };



    return observer;



    }



    var observer = setupObserver(“/storage/emulated/0”);




    observer.startWatching();



    Android.makeNewToast(“setup complete”).show();

    ]]>

  2. Anonymous says:

    < ![CDATA[

    Well after re-reading the docs, FileObserver is an abstract class, so I need to create a class that extends from FileObserver.. How can I do this in JS ?

    ]]>

  3. Anonymous says:

    < ![CDATA[

    You need something called Java Adapter


    I never used it, but it is something like


    new JavaAdapter(FileObserver(pathToWatch),{ …} );

    ]]>

  4. Anonymous says:

    < ![CDATA[

    TrianguloY how do you know this?

    ]]>

  5. Anonymous says:

    < ![CDATA[

    Because Lukas Morawietz​ found it, but that function was obfuscated, and asked Pierre Hébert​ to not obfuscate it.


    And I read the post 🙂

    ]]>

  6. Anonymous says:

    < ![CDATA[

    Maybe it has something to do with the Java2JS engine.. Do you know his name?

    ]]>

  7. Anonymous says:

    < ![CDATA[

    1. Yes, Java adapter would be the right thing to use, but


    2. Java adapter doesn’t work on Android, because it needs Java bytecode.


    3. I asked the developers of Rhino and they said: it would theoretically be possible to adjust this for android, but it’s a lot of work and it’s not planned.


    4. The only way to extend a class is to ship it in an apk and then load it in the script.

    ]]>

  8. Anonymous says:

    < ![CDATA[

    I see..

    ]]>

Leave a Reply

Your email address will not be published. Required fields are marked *