File tree 1 file changed +7
-2
lines changed
packages/core/application
1 file changed +7
-2
lines changed Original file line number Diff line number Diff line change @@ -265,6 +265,9 @@ export class AndroidApplication extends ApplicationCommon implements IAndroidApp
265
265
readonly activityRequestPermissionsEvent = AndroidApplication . activityRequestPermissionsEvent ;
266
266
267
267
private _nativeApp : android . app . Application ;
268
+ private _context : android . content . Context ;
269
+ private _packageName : string ;
270
+
268
271
// we are using these property to store the callbacks to avoid early GC collection which would trigger MarkReachableObjects
269
272
private lifecycleCallbacks : NativeScriptLifecycleCallbacks ;
270
273
private componentCallbacks : NativeScriptComponentCallbacks ;
@@ -279,6 +282,8 @@ export class AndroidApplication extends ApplicationCommon implements IAndroidApp
279
282
}
280
283
281
284
this . _nativeApp = nativeApp ;
285
+ this . _context = nativeApp . getApplicationContext ( ) ;
286
+ this . _packageName = nativeApp . getPackageName ( ) ;
282
287
283
288
// we store those callbacks and add a function for clearing them later so that the objects will be eligable for GC
284
289
this . lifecycleCallbacks = new NativeScriptLifecycleCallbacks ( ) ;
@@ -381,11 +386,11 @@ export class AndroidApplication extends ApplicationCommon implements IAndroidApp
381
386
}
382
387
383
388
get context ( ) {
384
- return this . nativeApp . getApplicationContext ( ) ;
389
+ return this . _context ;
385
390
}
386
391
387
392
get packageName ( ) {
388
- return this . nativeApp . getPackageName ( ) ;
393
+ return this . _packageName ;
389
394
}
390
395
391
396
public registerBroadcastReceiver ( intentFilter : string , onReceiveCallback : ( context : android . content . Context , intent : android . content . Intent ) => void ) : void {
You can’t perform that action at this time.
0 commit comments