Note that there are some explanatory texts on larger screens.

plurals
  1. POAndroid Facebook API - StringBuilder returns NULL
    primarykey
    data
    text
    <p>I'm working through the Android Facebook tutorial here: <a href="https://developers.facebook.com/docs/howtos/androidsdk/3.0/fetch-user-data/" rel="nofollow">https://developers.facebook.com/docs/howtos/androidsdk/3.0/fetch-user-data/</a></p> <p>In this chunk of code: </p> <pre><code>private String buildUserInfoDisplay(GraphUser user) { StringBuilder userInfo = new StringBuilder(""); Log.d("Graphuser:user",user.toString()); Log.d("StringBuilder:userInfo",userInfo.toString()); // Example: typed access (name) // - no special permissions required Log.d("Name: ",String.format("Name: %s\n\n", user.getName())); userInfo.append(String.format("Name: %s\n\n", user.getName())); // Example: typed access (birthday) // - requires user_birthday permission //userInfo.append(String.format("Birthday: %s\n\n", user.getBirthday())); // Example: partially typed access, to location field, // name key (location) // - requires user_location permission //userInfo.append(String.format("Location: %s\n\n", user.getLocation().getProperty("name"))); // Example: access via property name (locale) // - no special permissions required userInfo.append(String.format("Locale: %s\n\n", user.getProperty("locale"))); // Get a list of languages from an interface that // extends the GraphUser interface and that returns // a GraphObject list of MyGraphLanguage objects. GraphObjectList&lt;MyGraphLanguage&gt; languages = (user.cast(MyGraphUser.class)).getLanguages(); Log.d("Languages",languages.toString()); if (languages.size() &gt; 0) { ArrayList&lt;String&gt; languageNames = new ArrayList&lt;String&gt; (); // Iterate through the list of languages for (MyGraphLanguage language : languages) { // Add the language name to a list. Use the name // getter method to get access to the name field. languageNames.add(language.getName()); } //userInfo.append(String.format("Languages: %s\n\n", languageNames.toString())); } return userInfo.toString(); } </code></pre> <p>The <strong>userInfo.append()</strong> function results in a null pointer exception. Has anyone run into this before? I have checked that I have the same code as what is in the tutorial. </p> <p>/* Update - Append Logcat */</p> <pre><code>03-16 17:59:18.154: W/dalvikvm(1189): threadid=1: thread exiting with uncaught exception (group=0x40a13300) 03-16 17:59:18.204: E/AndroidRuntime(1189): FATAL EXCEPTION: main 03-16 17:59:18.204: E/AndroidRuntime(1189): java.lang.NullPointerException 03-16 17:59:18.204: E/AndroidRuntime(1189): at net.myname.myapp.MainFragment.buildUserInfoDisplay(MainFragment.java:84) 03-16 17:59:18.204: E/AndroidRuntime(1189): at net.myname.myapp.MainFragment.access$2(MainFragment.java:56) 03-16 17:59:18.204: E/AndroidRuntime(1189): at net.myname.myapp.MainFragment$2.onCompleted(MainFragment.java:125) 03-16 17:59:18.204: E/AndroidRuntime(1189): at com.facebook.Request$1.onCompleted(Request.java:264) 03-16 17:59:18.204: E/AndroidRuntime(1189): at com.facebook.Request$4.run(Request.java:1240) 03-16 17:59:18.204: E/AndroidRuntime(1189): at android.os.Handler.handleCallback(Handler.java:615) 03-16 17:59:18.204: E/AndroidRuntime(1189): at android.os.Handler.dispatchMessage(Handler.java:92) 03-16 17:59:18.204: E/AndroidRuntime(1189): at android.os.Looper.loop(Looper.java:137) 03-16 17:59:18.204: E/AndroidRuntime(1189): at android.app.ActivityThread.main(ActivityThread.java:4745) 03-16 17:59:18.204: E/AndroidRuntime(1189): at java.lang.reflect.Method.invokeNative(Native Method) 03-16 17:59:18.204: E/AndroidRuntime(1189): at java.lang.reflect.Method.invoke(Method.java:511) 03-16 17:59:18.204: E/AndroidRuntime(1189): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786) 03-16 17:59:18.204: E/AndroidRuntime(1189): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553) 03-16 17:59:18.204: E/AndroidRuntime(1189): at dalvik.system.NativeStart.main(Native Method) 03-16 17:59:18.354: D/dalvikvm(1189): GC_CONCURRENT freed 423K, 6% free 8428K/8903K, paused 107ms+76ms, total 316ms </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload