这是关于我的应用程序的一些细节。我有一个标签布局,使用Fragments
和一个ViewPager
. 在第三个选项卡上,我有一个 Google Map V2。现在,每当应用程序的用户在某个地标中时,他都可以在 Facebook 上分享有关该地标的详细信息。我已成功创建地图,但有关地标的详细信息尚未完成。现在关于facebook的“分享”功能,我已经按照facebook开发者的步骤。当我运行应用程序时,我收到错误:
10-17 14:19:06.856: E/AndroidRuntime(2180): java.lang.NullPointerException: Argument 'applicationId' cannot be null
并且经过搜索,我发现我需要将应用程序 ID 放在manifest.xml
.
这是我的元数据:
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="the key from google api console"
/>
<meta-data
android:name="com.facebook.sdk.ApplicationId"
android:value="the key from fb devs"
/>
但是,我仍然收到错误:
10-17 14:44:03.076: E/AndroidRuntime(2240): java.lang.NullPointerException: Argument 'applicationId' cannot be null
整个 facebook 分享对话框位于Fragment
.
这里是:
TabFour.java
public class TabFour extends Fragment {
private UiLifecycleHelper uiHelper;
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.activity_tab_four, container, false);
return rootView;
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
uiHelper = new UiLifecycleHelper(getActivity(), callback);
uiHelper.onCreate(savedInstanceState);
OpenGraphAction action = GraphObject.Factory.create(OpenGraphAction.class);
action.setProperty("book", "https://example.com/book/Snow-Crash.html");
@SuppressWarnings("deprecation")
FacebookDialog shareDialog = new FacebookDialog.OpenGraphActionDialogBuilder(getActivity(), action, "books.reads", "book")
.build();
uiHelper.trackPendingDialogCall(shareDialog.present());
}
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
uiHelper.onActivityResult(requestCode, resultCode, data, new FacebookDialog.Callback() {
@Override
public void onError(FacebookDialog.PendingCall pendingCall, Exception error, Bundle data) {
Log.e("Activity", String.format("Error: %s", error.toString()));
}
@Override
public void onComplete(FacebookDialog.PendingCall pendingCall, Bundle data) {
Log.i("Activity", "Success!");
}
});
}
@Override
public void onResume() {
super.onResume();
uiHelper.onResume();
}
@Override
public void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
uiHelper.onSaveInstanceState(outState);
}
@Override
public void onPause() {
super.onPause();
uiHelper.onPause();
}
@Override
public void onDestroy() {
super.onDestroy();
uiHelper.onDestroy();
}
private Session.StatusCallback callback = new Session.StatusCallback() {
@Override
public void call(Session session, SessionState state,
Exception exception) {
// TODO Auto-generated method stub
}
};
}
这是我的日志猫。