2014年12月4日 星期四
Android Facebook like button
// how to use LikeView in Android
before setting , download FBSDK newer version, please google it.
1. create android Project , get PackageName & hashkey & main activty
2. facebook dev page setting by(PackageName & hashkey & main activty) , and join test_user by yourself , get APP_ID.
3. project set APP_ID in manifest like this:
<meta-data
android:name="com.facebook.sdk.ApplicationId"
android:value="@string/facebook_app_id" />
4. LikeView setting:
// layout
<com.facebook.widget.LikeView
android:id="@+id/like_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
</com.facebook.widget.LikeView>
//class
private UiLifecycleHelper uiHelper;
LikeView like_view;
String like_url = "https://www.google.com.tw/";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
uiHelper = new UiLifecycleHelper(this,mStatusCallback);
like_view = (LikeView)findViewById(R.id.like_view);
like_view.setObjectId(like_url);
like_view.setLikeViewStyle(Style.BOX_COUNT);
}
StatusCallback mStatusCallback = new StatusCallback(){
@Override
public void call(Session session, SessionState state, Exception exception) {
}
};
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
uiHelper.onActivityResult(requestCode, resultCode, data, null);
}
PS: change like image method
jump to FBSDK lib_project find the com.facebook.internal.LikeButton => updateForLikeStatus() ,
訂閱:
張貼留言 (Atom)
沒有留言:
張貼留言