- Home /
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 https://developer.android.com/reference/android/content/pm/ShortcutInfo
I've found I need to use the nested 'ShortcutInfo.Builder' class to construct it. When I try the following
AndroidJavaObject b = new AndroidJavaObject("android.content.pm.ShortcutInfo.Builder", context, id);
(where context and id are correctly defined)
I get the error (using logcat)
AndroidJavaException: java.lang.ClassNotFoundException: android.content.pm.ShortcutInfo.Builder
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!
Answer by AkaLua · Jul 22, 2018 at 09:37 AM
Worked it out! When accessing nested classes, you need to use a ($) in place of a (.)
AndroidJavaObject b = new AndroidJavaObject("android.content.pm.ShortcutInfo$Builder", context, id);
Works perfectly now - hope this helps anyone with the same issue
Your answer
Follow this Question
Related Questions
Trouble with an array of classes - Cannot implicitly convert type 4 Answers
Error: 'transform' is not a member of 'Object' 2 Answers
Paint textures on an object 0 Answers
How put Android native code into c# unity 2 Answers
Android - Failed to sign APK package: Unsupported major.minor version 52.0 {SOLVED} 1 Answer