Using resource ids in a hotfix

Android assigns each resource a unique integer value. These values are auto generated and may change with each build. While applying a hotfix you may directly use the integer value you find in your resource file but we would not recommend that. Android provides an API to get these resources ids using their name. Say you want to find the id of a color in your hotfix. You can use the following code to get that.
 
int blueColor = activity.getResources().getIdentifier("blue", "color", activity.getPackageName());
 
This is equivalent to writing the following line in the source file.
 
int blueColor = R.color.blue;
 
We already have a few helper functions built-in to make your life easy while composing the hotfix. Following is the list of the helper functions. They are present in the class called io.hansel.pebbletracesdk.presets.UIPresets
public static View findViewById(android.app.Fragment fragment, String strId);
public static View findViewById(android.support.v4.app.Fragment fragment, String strId);
public static View findViewById(Activity activity, String strId);
public static View findViewById(Context activity, View superView, String strId);
public static void setVisibilityOnViewById(Activity activity, String strId, int visibility);
public static void setBackgroundColorOnViewById(Activity activity, String strId, int color);
public static void setTextOnViewById(Activity activity, String strId, String text);
Have more questions? Submit a request

0 Comments

Please sign in to leave a comment.