How to like a Facebook page on android?

社会主义新天地 提交于 2020-01-03 06:21:08

问题


I have managed to "Like" a non-Facebook webpage, but when I try Liking a Facebook one, using OpenGraph, I get: Like actions are not yet supported against objects of this type.

Is there any way to like a Facebook page using the Android Facebook SDK, not using a WebView?


回答1:


You can't directly like page. You will have to show that page in webView or native app. Then user will have to press like manually... It works like this to prevent manipulations on Fb counters.




回答2:


I assumes you have knowledge of developing app in facebook developer site. get your app id and paste id String resources.

xxxxxxxxxxxxxx

change your manifest.

///////////////////////////////Activity_main////////////////////

<com.facebook.widget.LikeView
        android:id="@+id/like_view"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="5dp"
        facebook:confirm_logout="false"
        facebook:fetch_user_info="true" />

/////////////////////////////////////////////Main Activity//////////////////

package com.example.loginfacebook;

import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import com.facebook.widget.LikeView;

public class MainActivity extends FragmentActivity {
    private LikeView like;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        setContentView(R.layout.activity_main);

        like = (LikeView) findViewById(R.id.like_view);


        like.setObjectId("https://www.facebook.com/appbellfitness");

    }

    @Override
    public void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        //uiHelper.onActivityResult(requestCode, resultCode, data);

        LikeView.handleOnActivityResult(getApplicationContext(), requestCode, resultCode, data);
    }



}

thats it... note(facebook doesnot allow directly like a page on native android button click.)



来源:https://stackoverflow.com/questions/20593595/how-to-like-a-facebook-page-on-android

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!