I want to fire an event from native android module and listen in on Titanium. I created a class in native module call Detector extending Kroll Proxy.
package com.detect.test; import org.appcelerator.kroll.KrollProxy; public class Detector extends KrollProxy { @Override public boolean fireEvent(String event, Object data) { // TODO Auto-generated method stub return super.fireEvent(event, data); } }In the android Kroll module extended class i created kroll method firing the event.
@Kroll.method public void detectDevice() { Detector newDectector = new Detector(); KrollDict newKrollDict = new KrollDict({device:"Detected"}); newDectector.fireEvent("deviceFound",newKrollDict); }I'm implementing a listener in the Titanium JS.
Ti.App.addEventListener('deviceDetected', function(e) { alert(e.device); });However this doesn't works. It throes force close on the app. Am I doing this right?