简体   繁体   中英

How to share text from android app to facebook?

I try to implement share button in my android app to share in facebook The code:

facebook.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

                Intent share = new Intent(android.content.Intent.ACTION_SEND);
                share.setType("text/plain");
                share.putExtra(Intent.EXTRA_SUBJECT,desc.getText().toString());
                startActivity(Intent.createChooser(share, "Share description using"));


            }
        });

The problem is, in the post dialog of the facebook not display the text which i need to share from my app which it is (desc.getText().toString()) . There empty message !! why the text didn't appear !!!

Thanks in advance

Try with this. Hope it help

Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("text/plain");
intent.putExtra(Intent.EXTRA_TEXT, "Share Something");
startActivity(Intent.createChooser(intent, "Share with"));

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