You can use facebook as a button in an Android application using special permission from the facebook developer account https://developers.facebook.com . Add your application here and send the special permission of the application. Go to the app overview and submit your content for approval. click on the start of the submission and after that select the LIKE native button and send all the details that they want, for example, why you want permission, how your application will use this permission for everything. If Facebook approves your request, you can use facebook as a button inside the application. enter code here
<com.facebook.share.widget.LikeView android:id="@+id/facebooklike" android:layout_width="wrap_content" android:layout_height="wrap_content"> </com.facebook.share.widget.LikeView>
After that you need to make java code.
likeView = (LikeView) findViewById(R.id.facebooklike); likeView.setLikeViewStyle(LikeView.Style.STANDARD); likeView.setAuxiliaryViewPosition(LikeView.AuxiliaryViewPosition.INLINE); likeView.setHorizontalAlignment(LikeView.HorizontalAlignment.CENTER); likeView.setObjectIdAndType("url of like page", LikeView.ObjectType.PAGE);
how the function is automatically called when you click on the button you like.
now you need to get a response from the same page as the user who is similar to this page, unlike this page.
enter code here
Public class FbLikes extends AppCompatActivity {
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_fb_likes); } @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); try { if (resultCode == RESULT_OK) { // verify we're returning from like action // get action results bundle = data.getExtras().getBundle("com.facebook.platform.protocol.RESULT_ARGS"); if (bundle != null) { like = bundle.getBoolean("object_is_liked");// liked/unliked bundle.getInt("didComplete"); bundle.getInt("like_count"); // object like count bundle.getString("like_count_string"); bundle.getString("social_sentence"); bundle.getString("completionGesture"); // liked/cancel/unliked Log.e(TAG, bundle.getString("social_sentence") + ""); Log.e(TAG, "likeornot" + bundle.getBoolean("object_is_liked") + ""); Log.e(TAG, "lcomplete" + bundle.getString("completionGesture") + ""); Log.e(TAG, "count" + bundle.getInt("like_count") + ""); Log.e(TAG, "countstr" + bundle.getString("like_count_string") + ""); Log.e(TAG, "did" + bundle.getInt("didComplete") + ""); } } } catch (Exception e) { } }
} this code will return everything you need from similar functions.
panik shamoor
source share