2012-11-15 109 views
8

我初學android.I想在我的Android application.I添加Facebook分享按鈕創建2.2應用程序。請幫我 我使用此代碼如何在Android應用程序添加Facebook的分享按鈕

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

+0

您將需要在你的帖子中提供更多細節。只是問你需要什麼不是如何工作。告訴我們你做了什麼,然後在你的代碼被困住時提出問題。 –

+0

呃。不在評論中。編輯您的帖子並在其中添加代碼。 –

+0

查看這兩個鏈接。它是學習初學者很好的例子。 - http://www.android10.org/index.php/articleslibraries/290-facebook-integration-in-your-android-application - http://www.integratingstuff.com/2010/10/14/integrating-facebook -into-an-android-application/ –

回答

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

使用ACTION_SEND意圖,添加你想要共享的URL。用戶將被給予選擇的應用程序來接受共享意圖,如Facebook等。

+0

它顯示對話框和我的設備中安裝的應用程序。我是否安裝Facebook應用程序的動作是在應用程序執行期間執行的,但該設備沒有facebook應用程序?如何分享內容到Facebook – dran

+0

我不知道任何URL類型的方法來共享數據到Facebook,可以簡單地在瀏覽器中打開,這種方法,你只會看到共享一個意圖的選擇ACTION_SEND –

+0

你可以做一個圖片一個消息在一起? – Lion789

相關問題