1

I have created an greeting card using textview and imageview, and used one button at the bottom, now I want on clicking that button it should invoke Facebook app to share it.I am using this code,correct me plz.

public void onFacebookButtonClicked(View view){
        String url = "https://www.facebook.com";
        Intent facebookIntent = new Intent(Intent.ACTION_SEND);
        facebookIntent.setData(Uri.parse(url));
        facebookIntent.setType("text/plain");
        facebookIntent.setPackage(url);
        facebookIntent.putExtra(Intent.EXTRA_TEXT, url);
        if (facebookIntent.resolveActivity(getPackageManager()) != null) {
            startActivity(facebookIntent);
        }
    }
JRG
  • 4,037
  • 3
  • 23
  • 34
  • perhaps this is something you need to look on Facebook developers website? https://developers.facebook.com/docs/sharing/android – letsCode Aug 15 '17 at 18:17
  • Possible duplicate of [Open Facebook page from Android app?](https://stackoverflow.com/questions/4810803/open-facebook-page-from-android-app) – JRG Aug 15 '17 at 18:20

0 Answers0