Sigi is an Android application framework for building native Android applications whilst using web technologies.
Coming soon: how to build a full Sigi app! Use the following to get started or check out these demos:
http://github.com/voltron/whoopingkof/tree/master/clients/android/
NOTE: The following assumes you know how to build a standard Android application using Eclipse or your favorite IDE or text editor.
Create a new Activity and change the class definition so it extends com.sigi.Sigi, not Activity.
Now, you need to add your extensions.
Add methods that will only be exposed to window object in WebView.
public interface IFooJS {
public String say(String word);
}
Implement methods of interface and extend AbstractWebViewExtension abstract base class.
public class Foo extends AbstractWebViewExtension implements IFooJS{}public void initialize()
{
// Add JS interface
webView.addJavascriptInterface((IFooJS) this, "Foo");
}
Implement interface methods in class definition.
public String say(String word){
return word+ " from Java";
}
In App.java (main app file), import your extension and create an arraylist of extensions and add your extension to the list inside the activity.
import com.myapp.foo;
/* In activity */
private ArrayList extensions = new ArrayList();
/* ... deeper in the Activity ... */
extensions.add(new Foo());
In your JavaScript file, call method like so:
var text = window.Foo.say('Text from JavaScript as well as ');
alert(text); // alerts "Text from JavaScript as well as from Java"
- Joe McCann http://github.com/joemccann
- David Wood http://github.com/davidwood/