Hello everybody i'm trying to get the returned values from an apprequest invite so i did this;

public void onComplete(Bundle values) {
final int[] to = values.getIntArray("to");
int n = to.length
}

But when i use the n variable this is the LogCat:

08-26 18:40:04.312: E/AndroidRuntime(6464): java.lang.NullPointerException

I have tryed with getIntArray, getFloatArray, getLongArray, getStringArray but nothing works. If i look the page of Facebook Developer it says this:

An array of the recipient user IDs for the request that was created.

But it doesn't say what is the array type. Thank You

有帮助吗?

解决方案

Thanks for nandeesh's hint, I found it's strange that we cannot retrieve the data in array type.

Every recipient user's ID should be retrieved with different keys.

I tried the following code and it works now.

Set<String> keys = values.keySet();
int userNum = values.keySet().size() - 1;
for (int i = 0; i < userNum; i++) {
    Log.d("user IDs", values.getString("to[" + String.format("%1$d", i) + "]"));
}
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top