gpt4 book ai didi

java - Facebook SDK friendPickerFragment.setOnSelectionChangedListener 导致 android 项目出错

转载 作者:行者123 更新时间:2023-11-29 21:29:00 24 4
gpt4 key购买 nike

我已经为我的项目设置了一个 OnSelectionChangedListener,如下所示:

friendPickerFragment.setOnSelectionChangedListener(new PickerFragment.OnSelectionChangedListener() {
@Override
public void onSelectionChanged(PickerFragment<?> fragment){
FriendPickerApplication application = (FriendPickerApplication) getApplication();
application.setSelectedUsers(friendPickerFragment.getSelection());

setResult(RESULT_OK, null);
finish();
}
});

这与 facebook sdk 示例应用程序“FriendPickerSample”中的 OnDoneButtonClickedListener 中的格式完全相同。我收到错误

java.lang.ClassCastException: android.app.Application cannot be cast to com.garrenkeith.facebook.FriendPickerApplication

我正在寻找一种解决方案来修复在选择用户时将所选用户添加到应用程序的代码。

最佳答案

检查 list 文件。您可能还没有配置您的 FriendPickerApplication <application> 中的类标签。

此外,您确定需要子类化“Application”吗?来自 Android 文档:

There is normally no need to subclass Application. In most situation, static singletons can provide the same functionality in a more modular way. If your singleton needs a global context (for example to register broadcast receivers), the function to retrieve it can be given a Context which internally uses Context.getApplicationContext() when first constructing the singleton.

关于java - Facebook SDK friendPickerFragment.setOnSelectionChangedListener 导致 android 项目出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19888836/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com