Facebook Android ShareDialog在開放後關閉
2022-09-04 06:08:55
在此之后,我在我的Android应用程序中使用Facebook sdk,为了进行测试,我已将以下代码添加到我的MainActivity中:
CallbackManager callbackManager;
ShareDialog shareDialog;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
FacebookSdk.sdkInitialize(getApplicationContext());
setContentView(R.layout.activity_main);
callbackManager = CallbackManager.Factory.create();
shareDialog = new ShareDialog(this);
if (ShareDialog.canShow(ShareLinkContent.class)) {
ShareLinkContent linkContent = new ShareLinkContent.Builder()
.setContentTitle("Hello Facebook")
.setContentDescription(
"The 'Hello Facebook' sample showcases simple Facebook integration")
.setContentUrl(Uri.parse("http://developers.facebook.com/android"))
.build();
shareDialog.show(linkContent);
}
}
我已经在我的清单中添加了以下步骤:
<uses-permission android:name="android.permission.INTERNET"/>
<meta-data android:name="com.facebook.sdk.ApplicationId" android:value="@string/facebook_app_id"/>
<provider android:authorities="com.facebook.app.FacebookContentProvider950310748347640"
android:name="com.facebook.FacebookContentProvider"
android:exported="true" />
<activity android:name="com.facebook.FacebookActivity"
android:configChanges=
"keyboard|keyboardHidden|screenLayout|screenSize|orientation"
android:theme="@android:style/Theme.Translucent.NoTitleBar"
android:label="@string/app_name" />
当我测试shareDialog时,弹出并突然关闭。