Android - Facebook ShareDialog在显示后几秒钟消失

时间:2015-03-27 14:14:29

标签: android facebook

为了在Android上的应用中添加ShareButton,我按照Facebook文档中的说明进行操作。

我设法在我的XML文件中添加ShareButton,并且每次点击它时都会让它做一些事情。但是,当我想要分享特定内容时,ShareDialog 会显示几秒钟,并自动关闭。

这是我的Manifest文件:

<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>

<view
    class="com.facebook.share.widget.ShareButton"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:id="@+id/view"
    android:layout_centerVertical="true"
    android:layout_centerHorizontal="true" />

Java主要活动:

@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>

0 个答案:

没有答案