android
android copied to clipboard
If you create a custom activity more than once an exception should be thrown
- Create new project
- Try to extend the
com.tns.NativeScriptActivity
, which is create by tns-core-modules Code:
var MyCustomActivityClass = (function (_super) {
__extends(MyCustomActivityClass, _super);
function MyCustomActivityClass() {
_super.call(this);
return global.__native(this);
}
MyCustomActivityClass.prototype.onCreate = function (savedInstanceState) {
_super.prototype.onCreate.call(this, false ? savedInstanceState : null);
android.util.Log.d("Sbg.Test","we got called from onCreate of custom-activity.js");
};
MyCustomActivityClass = __decorate([
JavaProxy("com.tns.NativeScriptActivity")
], MyCustomActivityClass);
return MyCustomActivityClass;
}(android.app.Activity));
- Build the app for android
tns build android
Actual: A warning will be logged "Warning: there already is an extend called com.tns.NativeScriptActivity." Expected: An exception to be thrown https://github.com/NativeScript/android-runtime/blob/2ab7271d12d56a03e57880a2b1783b08206363ae/test-app/build-tools/static-binding-generator/src/main/java/org/nativescript/staticbindinggenerator/Generator.java#L82
P.S. In some cases the exception is thrown, but this situations are very rare.