AndroidJavaObject Builder Class

Hi. I’m trying to add another shortcut to the home screen during run time, but I’m having trouble creating a ShortcutInfo object.

Reading through the page

I’ve found I need to use the nested ‘ShortcutInfo.Builder’ class to construct it. When I try the following

AndroidJavaObject b = new AndroidJavaObject("", context, id);

(where context and id are correctly defined)

I get the error (using logcat)

AndroidJavaException: java.lang.ClassNotFoundException:

Pretty sure I’m missing some really basic syntax, but Java is not my best language, and I’ve found little help online. I think its something to do with ShortcutInfo.Builder being a static class, but I might be completely wrong. Any help would be appreciated - thanks in advance!

Worked it out! When accessing nested classes, you need to use a ($) in place of a (.)

AndroidJavaObject b = new AndroidJavaObject("$Builder", context, id);

Works perfectly now - hope this helps anyone with the same issue