I am getting below error while sending color resource id from main app to library app (both is handled by me).
In main app, Theme is being changed dynamically so, I am passing the resource id of main app theme's primary color by adding it in intent extra as below
EDIT -- I am retrieving the theme's primary color as below in main app and sending it to libraray app.
private int getThemeColor() {
TypedValue typedValue = new TypedValue();
Resources.Theme theme = getActivity().getTheme();
theme.resolveAttribute(R.attr.colorPrimary, typedValue, true);
@ColorInt int color = typedValue.data;
return color;
}
//passing primary color to library app activity via intent
intent.putExtra("PRIMARY_COLOR",themeColor);
In library app I am retrieving the resource id as below
primaryColor = intent.getIntExtra("PRIMARY_COLOR", 0)
val res: Resources =
packageManager.getResourcesForApplication(callerPackageName)
primaryColor = res.getColor(primaryColor) //This line throws error