Issue
Google provides libGoogleAnalyticsServices.jar which can be initialized by calling
gaTracker = EasyTracker.getInstance(context);
In that case values needed for initialization (trackingId) are read from analytics.xml. I want add that ability to my library project. But reading the values requires having access to compiled R. class.
String s = getResources().getString(R.urls.myUrl);
as explained in this answer: Android How to add a custom xml file in res/values and how to register the customvalues.xml with the system
Is there a way to read the values using only the name of the value? I can not add a dependency on the main project.
Solution
I think they could did it like this:
String packageName = context.getPackageName();
int resId = context.getResources().getIdentifier("ga_trackingId", "string", packageName);
String val = context.getString(resId);
Log.d("String From Res", val);
Answered By - mirekkomis
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.