Android Titanium Module中的方法重载

时间:2016-07-26 01:10:17

标签: android titanium appcelerator appcelerator-titanium titanium-modules

是否可以为Titanium模块执行方法重载?专门针对Android

我有以下示例代码:

的Android

@Kroll.method
public void logout(KrollFunction callback)
{
    Log.d(LCAT, "start logout");
    final Activity activity = this.getActivity();
    final Branch instance = Branch.getInstance(activity);

    instance.logout();

    callback.call(getKrollObject(), new HashMap());
}

@Kroll.method
public void logout()
{
    Log.d(LCAT, "start logout");
    final Activity activity = this.getActivity();
    final Branch instance = Branch.getInstance(activity);

    instance.logout();
}

的Javascript

这不起作用

$.onlogoutClicked = function() {
    Ti.API.info("inside onlogoutClicked");
    branch.logout(function () {
        alert('Logout Session');
    });
}

这有效!

$.onlogoutClicked = function() {
    Ti.API.info("inside onlogoutClicked");
    branch.logout();
    alert('Logout Session');
}

请注意,我为注销实现了一个重载方法,您可以选择是否可以传递回调方法

所以我想知道如何为Titanium重载Java类方法?

0 个答案:

没有答案