简体   繁体   中英

Facebook Android SDK ShareDialog doesn't work

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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM