Finally Facebook and Launched Like Button for Android
Steps:
1 - Add Facebook Library to Project
2 - Create App on Facebook
3 - Update Manifest
**In the Application tab add meta-data**
<meta-data
android:name="com.facebook.sdk.ApplicationId"
android:value="@string/fb_id" />
4 - Add LikeView in Layout
//activitymain.xml
<com.facebook.widget.LikeView
android:id="@+id/like_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
>
</com.facebook.widget.LikeView>
5 - ActivityMain.java
//set facebook page or link to this like button
LikeView likeView;
UiLifecycleHelper uiHelper;
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activitymain);
uiHelper = new UiLifecycleHelper(this, null);
likeView = (LikeView) findViewById(R.id.like_view);
likeView.setObjectId("https://www.facebook.com/<page_username>");//it can be any link
likeView.setLikeViewStyle(LikeView.Style.STANDARD);
likeView.setAuxiliaryViewPosition(LikeView.AuxiliaryViewPosition.INLINE);
likeView.setHorizontalAlignment(LikeView.HorizontalAlignment.LEFT);
}
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
uiHelper.onActivityResult(requestCode, resultCode, data, null);
}
Output
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…