Facebook Android SDK ShareDialog doesn't work

徘徊边缘 提交于 2019-12-13 03:59:22

问题


I have a strange problem with Facebook Android SDK 4.0. I added all permissions,API_KEY and Hashkeys double checked they are OK. But I can't use ShareDialog on my Real Device which is API 15 and GenyMotion 4.4.4, 4.4.2.

When I try to open ShareDialog it appears without my content. It opens empty on my real device. But it works perfectly on GenyMotion 4.2.1, I tried to open GenyMotion 4.4.4 and 4.4.2 but these emulators don't open Facebook App. They are redirecting me to web view. When I enter my information on the webview I can see my all content so it's working again.

How can it be ? My Real Device doesn't post anything but GenyMotion 4.2.1 does work fine ? What is the problem ?

This is my AndroidManifest.xml;

    <uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.CALL_PHONE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />

<uses-permission android:name="android.permission.SET_DEBUG_APP"/>

<uses-feature
    android:glEsVersion="0x00020000"
    android:required="true" />

<application
    android:name=".GlobalState"
    android:allowBackup="true"
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/Theme.vet" >

    <provider android:authorities="com.facebook.app.FacebookContentProvider351533225052233"
        android:name="com.facebook.FacebookContentProvider"
        android:exported="true" />

    <meta-data
        android:name="com.google.android.gms.version"
        android:value="@integer/google_play_services_version" />
    <meta-data
        android:name="com.google.android.maps.v2.API_KEY"
        android:value="@string/API_KEY" />

    <meta-data
        android:name="com.facebook.sdk.ApplicationId"
        android:value="@string/facebook_app_id"/>

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

This is my Application class;

@Override
public void onCreate() {
    super.onCreate();

    // Enable Local Datastore.
    Parse.enableLocalDatastore(this);

    Parse.initialize(this, "KEY", "KEY");

    FacebookSdk.sdkInitialize(getApplicationContext());

}

This is my MainActivity.class;

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    setHasOptionsMenu(true);
    return inflater.inflate(R.layout.fragment_harita, container, false);
}

public void onViewCreated(View view, Bundle savedInstanceState){
    setupMap();
    //showGPSDisableAlert();

    FacebookSdk.sdkInitialize(getActivity().getApplicationContext());
    callbackManager = CallbackManager.Factory.create();
    shareDialog = new ShareDialog(this);
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
    int id = item.getItemId();
    if (id == R.id.action_share) {
if (ShareDialog.canShow(ShareLinkContent.class)) {
                            ShareLinkContent linkContent = new ShareLinkContent.Builder()
                                    .setContentTitle("vet !")
                                    .setContentDescription(
                                            "asd")
                                    .setContentUrl(Uri.parse("https://facebook.com/vet"))
                                    .build();

                            shareDialog.show(linkContent);}

Please help me to solve this problem. Thank you !

Sorry for my bad English.


回答1:


Try to update your facebook app on the real device, then put Log.i() message to get log from facebook api Try also to empty the application cache memory and reinstall it. In parallel try to test this sample application from facebook SDK https://github.com/facebook/facebook-android-sdk/tree/master/samples/Scrumptious



来源:https://stackoverflow.com/questions/29328377/facebook-android-sdk-sharedialog-doesnt-work

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!