What is the use of the res/values/public.xml file on Android?

The file res/values/public.xml is used to assign fixed resource IDs to Android resources. Consider these set of string resources in res/values/strings.xml: <?xml version=”1.0″ encoding=”utf-8″?> <resources> <string name=”string1″>String 1</string> <string name=”string3″>String 3</string> </resources> The Android Asset Packaging Tool (aapt) might assign the following resource IDs for these resources when the app is compiled: public final class … Read more

Duplicate value for resource ‘attr/font’ with config “

It may the concept that makes conflicts with the logic that we have previously used for apply Custom fonts. Previously We have used below code for creating the custom attribute for the font. <declare-styleable name=”CustomFont”> <attr name=”font” format=”string” /> </declare-styleable> What I change In my case, this was the issue and I have resolved it … Read more

How to fix: android.app.RemoteServiceException: Bad notification posted from package *: Couldn’t create icon: StatusBarIcon

What was happening was, I was including the integer reference to the icon in the PendingIntent bundle, and that integer was later being referenced while being posted to the NotificationManager. In between getting the integer reference and the pending intent going off, the app was updated and all of the drawable references changed. The integer … Read more

Programmatically change the value of a color resource obtained from API response

You can create a class which extends Resources and override the methods getColor(int) and getColor(int, Theme). Example: colors.xml <?xml version=”1.0″ encoding=”utf-8″?> <resources> <color name=”your_special_color”>#FF0099CC</color> </resources> Res.java public class Res extends Resources { public Res(Resources original) { super(original.getAssets(), original.getDisplayMetrics(), original.getConfiguration()); } @Override public int getColor(int id) throws NotFoundException { return getColor(id, null); } @Override public int … Read more

Android XML Percent Symbol

The Android Asset Packaging Tool (aapt) has become very strict in its latest release and is now used for all Android versions. The aapt-error you’re getting is generated because it no longer allows non-positional format specifiers. Here are a few ideas how you can include the %-symbol in your resource strings. If you don’t need … Read more