Consider I have an Activity “ProductsActivity” and “AddItemsActvity” , I need the Context of ProductsActivity in AddItemsActvity.
Are there any suggestions or methods to pass Context among activities in android.
Consider I have an Activity ProductsActivity and AddItemsActvity , I need the Context of
Share
The “Context of ProductsActivity” is actually the instance of ProductsActivity (Activity is derived from Context). So what you want is to pass a reference of ProductsActivity to AddItemsActivity.
This is not a good idea, as your ProductsActivity can get stopped and destroyed while your AddItemsActivity is running. You usually don’t want to pass Activity pointers around.