如何在Android应用程序中添加Facebook Share按钮

时间:2012-11-15 11:13:55

标签: android facebook

我是android的初学者。我想在我的android应用程序中添加自己的按钮。我在2.2中创建应用程序。请帮助我 我用这个代码

Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
emailIntent.setType("text/plain"); 
emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT,getResources().getStri‌​ng(R.string.title_activity_android_face_book_share));
emailIntent.putExtra(android‌​.content.Intent.EXTRA_TEXT,getResources().getString(R.string.title_activity_android_face_book_share));  
startActivity(emailIntent); 

我也使用以下链接Best way for social sharing in Android

1 个答案:

答案 0 :(得分:24)

  Intent shareIntent = new Intent(Intent.ACTION_SEND);
  shareIntent.setType("text/plain");
  shareIntent.putExtra(Intent.EXTRA_TEXT, "URLyouWantToShare");
  startActivity(Intent.createChooser(shareIntent, "Share..."));

使用ACTION_SEND意图,添加您要共享的网址。用户将获得一系列应用以接受分享意图,例如facebook等。

相关问题