9

Facebookでいくつかのコンテンツを共有しようとしていますが、多くの問題があります。正しいキーハッシュを追加し、Facebook でアプリを作成して公開しました。私が何かを共有しようとすると、あなたが見ることができるように良いようです:

ここに画像の説明を入力

しかし、投稿をクリックした後は空です: ここに画像の説明を入力

それは許可の問題ですか?私はスタックでこれについてたくさん読んだことがありますが、うまくいく答えが見つかりません...それがコードです:

public boolean onOptionsItemSelected(MenuItem item) {
        switch (item.getItemId()) 
        {
            case R.id.action_share:         
                Intent intent2=new Intent(Intent.ACTION_SEND);
                intent2.setType("text/plain");
                intent2.putExtra(Intent.EXTRA_TEXT,"'"+ random + "'" + "\n"+"By Random Quotes"); 
                startActivity(Intent.createChooser(intent2, "Share via"));
                break;

                case R.id.randombut:
                     Frasi();

                case android.R.id.home:
                    Intent homeIntent = new Intent(this, MainActivity.class);
                    homeIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
                    startActivity(homeIntent);
                break;

                case R.id.facebook:
                    FacebookDialog shareDialog = new FacebookDialog.ShareDialogBuilder(this)
                    .setApplicationName("Random Quotes")
                    .setDescription(random)
                .setPicture("https://lh6.ggpht.com/1UJ89ho9pvVLPYS6NsFVQdb7KoQPALMhkw1w7DnNDqcfDYJ-tRxruaf2YLMLyqhnG_g=w300-rw")
                    .setLink("https://play.google.com/store/apps/details?id=com.techappstudios.randomquotes")
                    .build();
                    uiHelper.trackPendingDialogCall(shareDialog.present());

         }
        return true;
    }
4

3 に答える 3

0

これは許可に関連していると思います。publish_actions 許可を要求する必要があります。初めて、Facebook は新しい許可を受け入れるように求めます。承認すると、共有ダイアログが直接表示されます。

これは私がしたことですが、コードを共有情報に置き換えます。

final Session activteSession  = Session.getActiveSession();
        if(!activteSession.isPermissionGranted("publish_actions")) {
            Session.getActiveSession().requestNewPublishPermissions(new Session.NewPermissionsRequest(this, "publish_actions"));
        }
        FacebookDialog shareDialog = new FacebookDialog.ShareDialogBuilder(this)
                .setApplicationName("Random Quotes")
                .setDescription(random)
            .setPicture("https://lh6.ggpht.com/1UJ89ho9pvVLPYS6NsFVQdb7KoQPALMhkw1w7DnNDqcfDYJ-tRxruaf2YLMLyqhnG_g=w300-rw")
                .setLink("https://play.google.com/store/apps/details?id=com.techappstudios.randomquotes")
                .build();
                uiHelper.trackPendingDialogCall(shareDialog.present());
        mFacebookUIHelper.trackPendingDialogCall(shareDialog.present());

これが役立つことを願っています。

于 2014-12-10T07:54:11.903 に答える