@@ -109,39 +109,49 @@ The core modules ship with a default `androidx.appcompat.app.AppCompatActivity`
109
109
110
110
const superProto = androidx.appcompat.app.AppCompatActivity.prototype;
111
111
androidx.appcompat.app.AppCompatActivity.extend("org.myApp.MainActivity", {
112
- onCreate: function(savedInstanceState) {
113
- // Set the isNativeScriptActivity in onCreate (as done in the original NativeScript activity code)
114
- // The JS constructor might not be called because the activity is created from Android.
115
- this.isNativeScriptActivity = true;
116
- if(!this._callbacks) {
117
- frame.setActivityCallbacks(this);
118
- }
119
- // Modules will take care of calling super.onCreate, do not call it here
120
- this._callbacks.onCreate(this, savedInstanceState, this.getIntent(), superProto.onCreate);
121
-
122
- // Add custom initialization logic here
123
- },
124
- onSaveInstanceState: function(outState) {
125
- this._callbacks.onSaveInstanceState(this, outState, superProto.onSaveInstanceState);
126
- },
127
- onStart: function() {
128
- this._callbacks.onStart(this, superProto.onStart);
129
- },
130
- onStop: function() {
131
- this._callbacks.onStop(this, superProto.onStop);
132
- },
133
- onDestroy: function() {
134
- this._callbacks.onDestroy(this, superProto.onDestroy);
135
- },
136
- onBackPressed: function() {
137
- this._callbacks.onBackPressed(this, superProto.onBackPressed);
138
- },
139
- onRequestPermissionsResult: function (requestCode, permissions, grantResults) {
140
- this._callbacks.onRequestPermissionsResult(this, requestCode, permissions, grantResults, undefined);
141
- },
142
- onActivityResult: function (requestCode, resultCode, data) {
143
- this._callbacks.onActivityResult(this, requestCode, resultCode, data, _super.prototype.onActivityResult);
144
- }
112
+ onCreate: function(savedInstanceState) {
113
+ // Used to make sure the App is inited in case onCreate is called before the rest of the framework
114
+ appModule.android.init(this.getApplication());
115
+
116
+ // Set the isNativeScriptActivity in onCreate (as done in the original NativeScript activity code)
117
+ // The JS constructor might not be called because the activity is created from Android.
118
+ this.isNativeScriptActivity = true;
119
+ if(!this._callbacks) {
120
+ frame.setActivityCallbacks(this);
121
+ }
122
+ // Modules will take care of calling super.onCreate, do not call it here
123
+ this._callbacks.onCreate(this, savedInstanceState, this.getIntent(), superProto.onCreate);
124
+
125
+ // Add custom initialization logic here
126
+ },
127
+ onNewIntent: function (intent) {
128
+ this._callbacks.onNewIntent(this, intent, superProto.setIntent, superProto.onNewIntent);
129
+ },
130
+ onSaveInstanceState: function(outState) {
131
+ this._callbacks.onSaveInstanceState(this, outState, superProto.onSaveInstanceState);
132
+ },
133
+ onStart: function() {
134
+ this._callbacks.onStart(this, superProto.onStart);
135
+ },
136
+ onStop: function() {
137
+ this._callbacks.onStop(this, superProto.onStop);
138
+ },
139
+ onDestroy: function() {
140
+ this._callbacks.onDestroy(this, superProto.onDestroy);
141
+ },
142
+ onPostResume: function () {
143
+ this._callbacks.onPostResume(this, superProto.onPostResume);
144
+ },
145
+ onBackPressed: function() {
146
+ this._callbacks.onBackPressed(this, superProto.onBackPressed);
147
+ },
148
+ onRequestPermissionsResult: function (requestCode, permissions, grantResults) {
149
+ this._callbacks.onRequestPermissionsResult(this, requestCode, permissions, grantResults, undefined);
150
+ },
151
+ onActivityResult: function (requestCode, resultCode, data) {
152
+ this._callbacks.onActivityResult(this, requestCode, resultCode, data, superProto.onActivityResult);
153
+ }
154
+ /* Add any other events you need to capture */
145
155
});
146
156
` ` `
147
157
` ` ` typescript
0 commit comments