I have Activity A, Activity B, and a static class in the same
application. The scenario is as follows (it’s simplified here; it
makes more sense in my software):
- (in Activity A) mAppctx = this.getApplicationContext();
- (in Activity A) StaticClass.appctx = mAppctx;
- Activity B is spawned
- Assume that Activity A is destroyed by the system while Activity B
is running - Activity B does the following (pseudo-code):
….. = StaticClass.appctx.getResources().openRawResource(…);
Is this correct?
Since an application Context belongs to the Application (i.e. to the
process), and not to the Activity, I suppose it’s correct, and APK
resources can be accessed in this way from the static class without
any problem. (I know that Activity B could actually ask getApplicationContext() on his own, but the above question is intentionally different.)
Yes, it is correct as both activity and aplication context access same resources.