2014-12-20 70 views
0

嗨,我一直在嘗試在我的Android應用上放置一個類似butto的Facebook,以便用戶能夠點擊我的Facebook頁面。facebook like button點擊時顯示空白頁面

我認爲我所做的一切都是爲在https://developers.facebook.com/docs/android/like-button/

但在點擊按鈕一樣定向在Facebook開發頁面,應用程序顯示空白頁,然後再次返回到應用程序。這裏是我一直在使用

這是我使用的佈局的一部分代碼:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:ads="http://schemas.android.com/apk/res-auto" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
android:orientation="vertical" > 

<LinearLayout 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:orientation="vertical" > 

    <ImageView 
     android:layout_width="match_parent" 
     android:layout_height="100dp" 
     android:contentDescription="@string/logo" 
     android:padding="10dp" 
     android:src="@drawable/nrnlogo" /> 

    <com.facebook.widget.LikeView 
     android:id="@+id/like_view" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:padding="5dp" /> 
</LinearLayout> 
</LinearLayout> 

的MainActivity.java如下。 我將必須實現它放置在片段中MainActivity.java

public static class HomeFragment extends Fragment{ 
    public static final String ARG_CATEGORY_NUMBER = "category_number"; 
    private UiLifecycleHelper uiHelper; 
    public int currentimageindex = 0; 
    private SwipeRefreshLayout swipeLayout; 
    //private Callback callback; 

    public HomeFragment() { 
     // Empty constructor required for fragment subclasses 
    } 

    @SuppressWarnings("deprecation") 
    @Override 
    public View onCreateView(LayoutInflater inflater, ViewGroup container, 
      Bundle savedInstanceState) { 
     View rootView = inflater.inflate(R.layout.fragment_home, container, 
       false); 

     //SWIPE TO REFRESH 
     swipeLayout = (SwipeRefreshLayout) rootView.findViewById(R.id.swipe_container); 
     //swipeLayout.setOnRefreshListener((OnRefreshListener) getActivity()); 
     swipeLayout.setColorScheme(android.R.color.holo_blue_bright, 
       android.R.color.holo_green_light, 
       android.R.color.holo_orange_light, 
       android.R.color.holo_red_light); 

     //SWIPE TO REFRESH 
     swipeLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() { 
      @Override 
      public void onRefresh() { 
       swipeLayout.setRefreshing(true); 
       Log.d("Swipe", "Refreshing Number"); 
       (new Handler()).postDelayed(new Runnable() { 
        @Override 
        public void run() { 
         swipeLayout.setRefreshing(false); 
         double f = Math.random(); 
        } 
       }, 3000); 
      } 
     }); 

     // FACEBOOK LIKE BUTTON 
     Settings.sdkInitialize(getActivity()); 
     //uiHelper = new UiLifecycleHelper(this.getActivity(), null); 
     LikeView likeView = (LikeView) rootView 
       .findViewById(R.id.like_view); 
     likeView.setObjectId("http://www.facebook.com/NewsNrnDotCom"); 
     //likeView.setForegroundColor(-256); 

     ListView hlvCategory = (ListView) rootView 
       .findViewById(R.id.group_content); 
     Log.e("Adapter Set Vertical", "ABC"); 
     AdView mAdView = (AdView) rootView.findViewById(R.id.adView); 
     HomeJsonData hjd = new HomeJsonData(getActivity(), hlvCategory, 
       mAdView, mDrawerList); 

     hjd.execute(); 

    // FACEBOOK LIKE BUTTON 
    @Override 
    public void onActivityResult(int requestCode, int resultCode, Intent data) { 
     super.onActivityResult(requestCode, resultCode, data); 
     LikeView.handleOnActivityResult(getActivity(), requestCode, resultCode, data); 
     //uiHelper.onActivityResult(requestCode, resultCode, data, null); 
    } 
} 

誰能告訴我,因爲我已什麼錯誤?

回答

1

您是否在您的應用中使用了FB測試用戶帳戶?測試帳戶不允許喜歡一個頁面。我有同樣的問題。我更改爲使用我的實際FB帳戶和LikeButton工作得很好

+0

使用實際的FB帳戶顯示相同的問題 找不到解決方案,我放棄了此過程,而是使用意圖顯示Facebook頁面按鈕被點擊。 –