Android-Facebook共享对话框在显示几秒钟后消失

Android-Facebook共享对话框在显示几秒钟后消失,android,facebook,Android,Facebook,为了在我的Android应用程序中添加一个ShareButton,我遵循了Facebook文档中的说明 我设法在XML文件中添加了一个ShareButton,并且每次单击它时都能让它做一些事情。但是,当我想共享特定内容时,ShareDialog会出现几秒钟,并自动关闭 这是我的清单文件: <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.omarlahlou.m

为了在我的Android应用程序中添加一个
ShareButton
,我遵循了Facebook文档中的说明

我设法在XML文件中添加了一个
ShareButton
,并且每次单击它时都能让它做一些事情。但是,当我想共享特定内容时,
ShareDialog
会出现几秒钟,并自动关闭

这是我的
清单
文件:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.omarlahlou.myapplication" >
<uses-permission android:name="android.permission.INTERNET"/>

<application
    android:allowBackup="true"
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme" >

    <provider android:authorities="com.facebook.app.FacebookContentProvider1067903639891556"
        android:name="com.facebook.FacebookContentProvider"
        android:exported="true"/>
    <activity
        android:name=".MainActivity"
        android:label="@string/app_name" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
    <meta-data android:name="com.facebook.sdk.ApplicationId"
        android:value="@string/facebook_app_id"/>
</application>
最后,以下是日志:

03-27 15:05:24.743  14696-14696/com.example.omarlahlou.myapplication I/View﹕ Touch down dispatch to com.facebook.share.widget.ShareButton{41d22ce8 V.ED..C. ........ 350,528-449,569 #7f08004e app:id/view}, event = MotionEvent { action=ACTION_DOWN, id[0]=0, x[0]=70.47443, y[0]=4.4918213, toolType[0]=TOOL_TYPE_FINGER, buttonState=0, metaState=0, flags=0x0, edgeFlags=0x0, pointerCount=1, historySize=0, eventTime=4811186, downTime=4811186, deviceId=2, source=0x1002 }
03-27 15:05:24.765  14696-14696/com.example.omarlahlou.myapplication D/GraphicBuffer﹕ create handle(0x60cc1200) (w:800, h:1216, f:1)
03-27 15:05:24.769  14696-14696/com.example.omarlahlou.myapplication D/OpenGLRenderer﹕ prepareDirty (0.00, 0.00, 800.00, 1216.00) opaque 1 <0x60a50408>
03-27 15:05:24.771  14696-14696/com.example.omarlahlou.myapplication D/OpenGLRenderer﹕ finish <0x60a50408>
03-27 15:05:24.843  14696-14696/com.example.omarlahlou.myapplication I/View﹕ Touch up dispatch to com.facebook.share.widget.ShareButton{41d22ce8 V.ED..C. ...P.... 350,528-449,569 #7f08004e app:id/view}, event = MotionEvent { action=ACTION_UP, id[0]=0, x[0]=70.47443, y[0]=4.4918213, toolType[0]=TOOL_TYPE_FINGER, buttonState=0, metaState=0, flags=0x0, edgeFlags=0x0, pointerCount=1, historySize=0, eventTime=4811287, downTime=4811186, deviceId=2, source=0x1002 }
03-27 15:05:24.843  14696-14696/com.example.omarlahlou.myapplication V/Provider/Settings﹕ from settings cache , name = sound_effects_enabled , value = 0
03-27 15:05:24.848  14696-14696/com.example.omarlahlou.myapplication D/ActivityThread﹕ hoder:android.app.IActivityManager$ContentProviderHolder@41d495b8,provider,holder.Provider:android.content.ContentProviderProxy@41caeed0
03-27 15:05:24.895  14696-14696/com.example.omarlahlou.myapplication D/GraphicBuffer﹕ create handle(0x60cfb0b8) (w:800, h:1216, f:1)
03-27 15:05:24.899  14696-14696/com.example.omarlahlou.myapplication D/OpenGLRenderer﹕ prepareDirty (0.00, 0.00, 800.00, 1216.00) opaque 1 <0x60a50408>
03-27 15:05:24.900  14696-14696/com.example.omarlahlou.myapplication D/OpenGLRenderer﹕ finish <0x60a50408>
03-27 15:05:24.743 14696-14696/com.example.omarlahlou.myapplication I/View﹕ 点击发送到com.facebook.share.widget.ShareButton{41d22ce8 V.ED..C....350528-449569#7f08004e应用程序:id/view},event=MotionEvent{action=action\u down,id[0]=0,x[0]=70.47443,y[0]=4.4918213,工具类型[0]=TOOL_TYPE_FINGER,buttonState=0,metaState=0,flags=0x0,edgeFlags=0x0,pointerCount=1,historySize=0,eventTime=4811186,downless=4811186,deviceId=2,source=0x1002}
03-27 15:05:24.765 14696-14696/com.example.omarlahlou.myapplication D/GraphicBuffer﹕ 创建句柄(0x60cc1200)(w:800,h:1216,f:1)
03-27 15:05:24.769 14696-14696/com.example.omarlahlou.myapplication D/OpenGLRenderer﹕ 准备时间(0.00,0.00,800.00,1216.00)不透明1
03-27 15:05:24.771 14696-14696/com.example.omarlahlou.myapplication D/opengl﹕ 完成
03-27 15:05:24.843 14696-14696/com.example.omarlahlou.myapplication I/View﹕ 更新发送到com.facebook.share.widget.ShareButton{41d22ce8 V.ED..C..P..350528-449569#7f08004e应用程序:id/view},event=MotionEvent{action=action\u up,id[0]=0,x[0]=70.47443,y[0]=4.4918213,工具类型[0]=TOOL_TYPE_FINGER,buttonState=0,metaState=0,flags=0x0,edgeFlags=0x0,pointerCount=1,historySize=0,eventTime=4811287,downless=4811186,deviceId=2,source=0x1002}
03-27 15:05:24.843 14696-14696/com.example.omarlahlou.myapplication V/Provider/Settings﹕ 从设置缓存中,名称=声音效果,值=0
03-27 15:05:24.848 14696-14696/com.example.omarlahlou.myapplication D/ActivityThread﹕ 霍德:android.app.IActivityManager$ContentProviderHolder@41d495b8,提供者,持有者。提供者:android.content。ContentProviderProxy@41caeed0
03-27 15:05:24.895 14696-14696/com.example.omarlahlou.myapplication D/GraphicBuffer﹕ 创建句柄(0x60cfb0b8)(w:800,h:1216,f:1)
03-27 15:05:24.899 14696-14696/com.example.omarlahlou.myapplication D/opengl﹕ 准备时间(0.00,0.00,800.00,1216.00)不透明1
03-27 15:05:24.900 14696-14696/com.example.omarlahlou.myapplication D/opengl﹕ 完成

您有什么问题?共享对话框将自动关闭。我真的不知道为什么。除了你提供的片段之外,应该还有更多的logcat信息。此外,了解您使用的SDK版本也会很有帮助。事实上,它会消失,因为在我的测试设备上,我没有连接到Facebook帐户。请注意,您需要使用Developer Facebook帐户进行连接。@OmarLahlou那么,当我们想将应用程序发布到市场时,我们应该怎么做?如果不使用开发人员帐户,使用release ssh密钥是否有效?
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    FacebookSdk.sdkInitialize(getApplicationContext());
    setContentView(R.layout.activity_main);

    ShareButton myShareButton = (ShareButton)findViewById(R.id.view);

    ShareLinkContent content = new ShareLinkContent.Builder()
            .setContentUrl(Uri.parse("https://developers.facebook.com"))
            .build();

    myShareButton.setShareContent(content);
}
03-27 15:05:24.743  14696-14696/com.example.omarlahlou.myapplication I/View﹕ Touch down dispatch to com.facebook.share.widget.ShareButton{41d22ce8 V.ED..C. ........ 350,528-449,569 #7f08004e app:id/view}, event = MotionEvent { action=ACTION_DOWN, id[0]=0, x[0]=70.47443, y[0]=4.4918213, toolType[0]=TOOL_TYPE_FINGER, buttonState=0, metaState=0, flags=0x0, edgeFlags=0x0, pointerCount=1, historySize=0, eventTime=4811186, downTime=4811186, deviceId=2, source=0x1002 }
03-27 15:05:24.765  14696-14696/com.example.omarlahlou.myapplication D/GraphicBuffer﹕ create handle(0x60cc1200) (w:800, h:1216, f:1)
03-27 15:05:24.769  14696-14696/com.example.omarlahlou.myapplication D/OpenGLRenderer﹕ prepareDirty (0.00, 0.00, 800.00, 1216.00) opaque 1 <0x60a50408>
03-27 15:05:24.771  14696-14696/com.example.omarlahlou.myapplication D/OpenGLRenderer﹕ finish <0x60a50408>
03-27 15:05:24.843  14696-14696/com.example.omarlahlou.myapplication I/View﹕ Touch up dispatch to com.facebook.share.widget.ShareButton{41d22ce8 V.ED..C. ...P.... 350,528-449,569 #7f08004e app:id/view}, event = MotionEvent { action=ACTION_UP, id[0]=0, x[0]=70.47443, y[0]=4.4918213, toolType[0]=TOOL_TYPE_FINGER, buttonState=0, metaState=0, flags=0x0, edgeFlags=0x0, pointerCount=1, historySize=0, eventTime=4811287, downTime=4811186, deviceId=2, source=0x1002 }
03-27 15:05:24.843  14696-14696/com.example.omarlahlou.myapplication V/Provider/Settings﹕ from settings cache , name = sound_effects_enabled , value = 0
03-27 15:05:24.848  14696-14696/com.example.omarlahlou.myapplication D/ActivityThread﹕ hoder:android.app.IActivityManager$ContentProviderHolder@41d495b8,provider,holder.Provider:android.content.ContentProviderProxy@41caeed0
03-27 15:05:24.895  14696-14696/com.example.omarlahlou.myapplication D/GraphicBuffer﹕ create handle(0x60cfb0b8) (w:800, h:1216, f:1)
03-27 15:05:24.899  14696-14696/com.example.omarlahlou.myapplication D/OpenGLRenderer﹕ prepareDirty (0.00, 0.00, 800.00, 1216.00) opaque 1 <0x60a50408>
03-27 15:05:24.900  14696-14696/com.example.omarlahlou.myapplication D/OpenGLRenderer﹕ finish <0x60a50408>