2015-02-05 242 views
0

Hj everyone,我是一名與Facebook sdk合作的新手。如何在Facebook上使用測試應用程序在Android上運行Facebook應用程序開發人員

我已經在Facebook開發者中創建了一個應用程序,添加了包,關鍵哈希..然後我創建了一個測試應用程序來測試我的應用程序。 但是當我運行我的項目時,在我的設備上運行應用程序,它無法登錄到獲取數據。

02-05 11:01:14.276: W/fb4a(:<default>):BlueServiceQueue(3430): Exception during service 
02-05 11:01:14.276: W/fb4a(:<default>):BlueServiceQueue(3430): com.facebook.http.protocol.ApiException: [code] 100 [message]: Invalid permission: user_online_presence [extra]: null 
02-05 11:01:14.276: W/fb4a(:<default>):BlueServiceQueue(3430): at com.facebook.http.protocol.ApiResponseChecker.b(ApiResponseChecker.java:84) 
02-05 11:01:14.276: W/fb4a(:<default>):BlueServiceQueue(3430): at com.facebook.http.protocol.ApiResponseChecker.a(ApiResponseChecker.java:163) 
02-05 11:01:14.276: W/fb4a(:<default>):BlueServiceQueue(3430): at com.facebook.http.protocol.ApiResponse.h(ApiResponse.java:188) 
02-05 11:01:14.276: W/fb4a(:<default>):BlueServiceQueue(3430): at com.facebook.platform.auth.server.AuthorizeAppMethod.a(AuthorizeAppMethod.java:275) 
02-05 11:01:14.276: W/fb4a(:<default>):BlueServiceQueue(3430): at com.facebook.platform.auth.server.AuthorizeAppMethod.a(AuthorizeAppMethod.java:31) 
02-05 11:01:14.276: W/fb4a(:<default>):BlueServiceQueue(3430): at com.facebook.http.protocol.ApiResponseHandler.a(ApiResponseHandler.java:55) 
02-05 11:01:14.276: W/fb4a(:<default>):BlueServiceQueue(3430): at com.facebook.http.protocol.ApiResponseHandler.handleResponse(ApiResponseHandler.java:28) 
02-05 11:01:14.276: W/fb4a(:<default>):BlueServiceQueue(3430): at com.facebook.http.common.FbHttpRequestProcessor.a(FbHttpRequestProcessor.java:699) 
02-05 11:01:14.276: W/fb4a(:<default>):BlueServiceQueue(3430): at com.facebook.http.common.FbHttpRequestProcessor.a(FbHttpRequestProcessor.java:206) 
02-05 11:01:14.276: W/fb4a(:<default>):BlueServiceQueue(3430): at com.facebook.http.common.FbHttpRequestProcessor.d(FbHttpRequestProcessor.java:159) 
02-05 11:01:14.276: W/fb4a(:<default>):BlueServiceQueue(3430): at com.facebook.http.common.FbHttpRequestProcessor.a(FbHttpRequestProcessor.java:314) 
02-05 11:01:14.276: W/fb4a(:<default>):BlueServiceQueue(3430): at com.facebook.http.protocol.SingleMethodRunnerImpl.a(SingleMethodRunnerImpl.java:527) 
02-05 11:01:14.276: W/fb4a(:<default>):BlueServiceQueue(3430): at com.facebook.http.protocol.SingleMethodRunnerImpl.a(SingleMethodRunnerImpl.java:251) 
02-05 11:01:14.276: W/fb4a(:<default>):BlueServiceQueue(3430): at com.facebook.http.protocol.AbstractSingleMethodRunner.a(AbstractSingleMethodRunner.java:20) 
02-05 11:01:14.276: W/fb4a(:<default>):BlueServiceQueue(3430): at com.facebook.platform.common.server.SimplePlatformOperation.a(SimplePlatformOperation.java:39) 
02-05 11:01:14.276: W/fb4a(:<default>):BlueServiceQueue(3430): at com.facebook.platform.common.server.PlatformOperationHandler.a(PlatformOperationHandler.java:59) 
02-05 11:01:14.276: W/fb4a(:<default>):BlueServiceQueue(3430): at com.facebook.fbservice.service.BlueServiceQueue.e(BlueServiceQueue.java:360) 
02-05 11:01:14.276: W/fb4a(:<default>):BlueServiceQueue(3430): at com.facebook.fbservice.service.BlueServiceQueue.d(BlueServiceQueue.java:58) 
02-05 11:01:14.276: W/fb4a(:<default>):BlueServiceQueue(3430): at com.facebook.fbservice.service.BlueServiceQueue$3.run(BlueServiceQueue.java:280) 
02-05 11:01:14.276: W/fb4a(:<default>):BlueServiceQueue(3430): at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:390) 
02-05 11:01:14.276: W/fb4a(:<default>):BlueServiceQueue(3430): at java.util.concurrent.FutureTask.run(FutureTask.java:234) 
02-05 11:01:14.276: W/fb4a(:<default>):BlueServiceQueue(3430): at com.facebook.common.executors.ListenableScheduledFutureImpl.run(ListenableScheduledFutureImpl.java:58) 
02-05 11:01:14.276: W/fb4a(:<default>):BlueServiceQueue(3430): at android.os.Handler.handleCallback(Handler.java:725) 
02-05 11:01:14.276: W/fb4a(:<default>):BlueServiceQueue(3430): at android.os.Handler.dispatchMessage(Handler.java:92) 
02-05 11:01:14.276: W/fb4a(:<default>):BlueServiceQueue(3430): at android.os.Looper.loop(Looper.java:137) 
02-05 11:01:14.276: W/fb4a(:<default>):BlueServiceQueue(3430): at android.os.HandlerThread.run(HandlerThread.java:60) 
02-05 11:01:14.286: W/fb4a(:<default>):GDPDialog(3430): Failed to send 
02-05 11:01:14.286: W/fb4a(:<default>):GDPDialog(3430): com.facebook.fbservice.service.ServiceException: API_ERROR: API_ERROR 
02-05 11:01:14.286: W/fb4a(:<default>):GDPDialog(3430):  at com.facebook.fbservice.ops.BlueServiceOperation.c(BlueServiceOperation.java:665) 
02-05 11:01:14.286: W/fb4a(:<default>):GDPDialog(3430):  at com.facebook.fbservice.ops.BlueServiceOperation.c(BlueServiceOperation.java:48) 
02-05 11:01:14.286: W/fb4a(:<default>):GDPDialog(3430):  at com.facebook.fbservice.ops.BlueServiceOperation$2.run(BlueServiceOperation.java:630) 
02-05 11:01:14.286: W/fb4a(:<default>):GDPDialog(3430):  at android.os.Handler.handleCallback(Handler.java:725) 
02-05 11:01:14.286: W/fb4a(:<default>):GDPDialog(3430):  at android.os.Handler.dispatchMessage(Handler.java:92) 
02-05 11:01:14.286: W/fb4a(:<default>):GDPDialog(3430):  at android.os.Looper.loop(Looper.java:137) 
02-05 11:01:14.286: W/fb4a(:<default>):GDPDialog(3430):  at android.app.ActivityThread.main(ActivityThread.java:5279) 
02-05 11:01:14.286: W/fb4a(:<default>):GDPDialog(3430):  at java.lang.reflect.Method.invokeNative(Native Method) 
02-05 11:01:14.286: W/fb4a(:<default>):GDPDialog(3430):  at java.lang.reflect.Method.invoke(Method.java:511) 
02-05 11:01:14.286: W/fb4a(:<default>):GDPDialog(3430):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1102) 
02-05 11:01:14.286: W/fb4a(:<default>):GDPDialog(3430):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:869) 
02-05 11:01:14.286: W/fb4a(:<default>):GDPDialog(3430):  at dalvik.system.NativeStart.main(Native Method) 
02-05 11:01:14.286: W/fb4a(:<default>):GDPDialog(3430): Caused by: com.facebook.http.protocol.ApiException: [code] 100 [message]: Invalid permission: user_online_presence [extra]: null 
02-05 11:01:14.286: W/fb4a(:<default>):GDPDialog(3430):  at com.facebook.http.protocol.ApiResponseChecker.b(ApiResponseChecker.java:84) 
02-05 11:01:14.286: W/fb4a(:<default>):GDPDialog(3430):  at com.facebook.http.protocol.ApiResponseChecker.a(ApiResponseChecker.java:163) 
02-05 11:01:14.286: W/fb4a(:<default>):GDPDialog(3430):  at com.facebook.http.protocol.ApiResponse.h(ApiResponse.java:188) 
02-05 11:01:14.286: W/fb4a(:<default>):GDPDialog(3430):  at com.facebook.platform.auth.server.AuthorizeAppMethod.a(AuthorizeAppMethod.java:275) 
02-05 11:01:14.286: W/fb4a(:<default>):GDPDialog(3430):  at com.facebook.platform.auth.server.AuthorizeAppMethod.a(AuthorizeAppMethod.java:31) 
02-05 11:01:14.286: W/fb4a(:<default>):GDPDialog(3430):  at com.facebook.http.protocol.ApiResponseHandler.a(ApiResponseHandler.java:55) 
02-05 11:01:14.286: W/fb4a(:<default>):GDPDialog(3430):  at com.facebook.http.protocol.ApiResponseHandler.handleResponse(ApiResponseHandler.java:28) 
02-05 11:01:14.286: W/fb4a(:<default>):GDPDialog(3430):  at com.facebook.http.common.FbHttpRequestProcessor.a(FbHttpRequestProcessor.java:699) 
02-05 11:01:14.286: W/fb4a(:<default>):GDPDialog(3430):  at com.facebook.http.common.FbHttpRequestProcessor.a(FbHttpRequestProcessor.java:206) 
02-05 11:01:14.286: W/fb4a(:<default>):GDPDialog(3430):  at com.facebook.http.common.FbHttpRequestProcessor.d(FbHttpRequestProcessor.java:159) 
02-05 11:01:14.286: W/fb4a(:<default>):GDPDialog(3430):  at com.facebook.http.common.FbHttpRequestProcessor.a(FbHttpRequestProcessor.java:314) 
02-05 11:01:14.286: W/fb4a(:<default>):GDPDialog(3430):  at com.facebook.http.protocol.SingleMethodRunnerImpl.a(SingleMethodRunnerImpl.java:527) 
02-05 11:01:14.286: W/fb4a(:<default>):GDPDialog(3430):  at com.facebook.http.protocol.SingleMethodRunnerImpl.a(SingleMethodRunnerImpl.java:251) 
02-05 11:01:14.286: W/fb4a(:<default>):GDPDialog(3430):  at com.facebook.http.protocol.AbstractSingleMethodRunner.a(AbstractSingleMethodRunner.java:20) 
02-05 11:01:14.286: W/fb4a(:<default>):GDPDialog(3430):  at com.facebook.platform.common.server.SimplePlatformOperation.a(SimplePlatformOperation.java:39) 
02-05 11:01:14.286: W/fb4a(:<default>):GDPDialog(3430):  at com.facebook.platform.common.server.PlatformOperationHandler.a(PlatformOperationHandler.java:59) 
02-05 11:01:14.286: W/fb4a(:<default>):GDPDialog(3430):  at com.facebook.fbservice.service.BlueServiceQueue.e(BlueServiceQueue.java:360) 
02-05 11:01:14.286: W/fb4a(:<default>):GDPDialog(3430):  at com.facebook.fbservice.service.BlueServiceQueue.d(BlueServiceQueue.java:58) 
02-05 11:01:14.286: W/fb4a(:<default>):GDPDialog(3430):  at com.facebook.fbservice.service.BlueServiceQueue$3.run(BlueServiceQueue.java:280) 
02-05 11:01:14.286: W/fb4a(:<default>):GDPDialog(3430):  at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:390) 
02-05 11:01:14.286: W/fb4a(:<default>):GDPDialog(3430):  at java.util.concurrent.FutureTask.run(FutureTask.java:234) 
02-05 11:01:14.286: W/fb4a(:<default>):GDPDialog(3430):  at com.facebook.common.executors.ListenableScheduledFutureImpl.run(ListenableScheduledFutureImpl.java:58) 
02-05 11:01:14.286: W/fb4a(:<default>):GDPDialog(3430):  at android.os.Handler.handleCallback(Handler.java:725) 
02-05 11:01:14.286: W/fb4a(:<default>):GDPDialog(3430):  at android.os.Handler.dispatchMessage(Handler.java:92) 
02-05 11:01:14.286: W/fb4a(:<default>):GDPDialog(3430):  at android.os.Looper.loop(Looper.java:137) 
02-05 11:01:14.286: W/fb4a(:<default>):GDPDialog(3430):  at android.os.HandlerThread.run(HandlerThread.java:60) 
02-05 11:01:14.356: W/ContextImpl(1097): Calling a method in the system process without a qualified user: android.app.ContextImpl.sendBroadcast:1375 com.android.server.am.ActivityStack.startPausingLocked:1408 com.android.server.am.ActivityStack.finishActivityLocked:5919 com.android.server.am.ActivityStack.finishActivityLocked:5833 com.android.server.am.ActivityStack.requestFinishActivityLocked:5749 

請幫我解決這個問題。 我沒有看到用於測試應用程序在Facebook開發人員添加權限

+0

安置自己的代碼在這裏也。 –

回答

0

這是代碼

public class LoginFragment extends Fragment { 
private LoginButton authButton; 
private ProgressBar progressBar; 

private UiLifecycleHelper uiHelper; 
private Session.StatusCallback callback = new Session.StatusCallback() { 
    @Override 
    public void call(Session session, SessionState state, 
      Exception exception) { 
     onSessionStateChange(session, state, exception); 
    } 
}; 

public interface LoginFragmentCallBack { 
    public void onUserInfoFetched(User user); 
} 

@Override 
public void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 
    uiHelper = new UiLifecycleHelper(getActivity(), callback); 
    uiHelper.onCreate(savedInstanceState); 
} 

@Override 
public View onCreateView(LayoutInflater inflater, ViewGroup container, 
     Bundle savedInstanceState) { 
    View view = inflater.inflate(R.layout.fragment_login, container, false); 

    authButton = (LoginButton) view.findViewById(R.id.authButton); 
    progressBar = (ProgressBar) view.findViewById(R.id.progressBar); 
    TextView tv = (TextView) view.findViewById(R.id.app_name_textview); 
    tv.setText(KlyphFlags.IS_PRO_VERSION == true ? R.string.app_pro_large_name 
      : R.string.app_large_name); 

    authButton.setReadPermissions(Arrays.asList("user_online_presence", 
      "friends_online_presence", "read_mailbox", "xmpp_login", 
      "email", "user_friends", "user_photos", "friends_photos")); 

    authButton 
      .setUserInfoChangedCallback(new LoginButton.UserInfoChangedCallback() { 

       @Override 
       public void onUserInfoFetched(GraphUser user) { 
        if (Session.getActiveSession().isOpened() 
          && user != null) { 

         User u = new User(); 
         u.setUid(user.getId()); 
         u.setName(user.getName()); 
         u.setFirst_name(user.getFirstName()); 
         u.setMiddle_name(user.getMiddleName()); 
         u.setLast_name(user.getLastName()); 
         u.setBirthday(user.getBirthday()); 
         u.setEmail((String) user.getProperty("email")); 
         u.setSex((String) user.getProperty("gender")); 
         // u.setIn((String) 
         // user.getProperty("interested_in")); 
         u.setLocale((String) user.getProperty("locale")); 
         u.setRelationship_status((String) user 
           .getProperty("relationship_status")); 
         u.setUsername((String) user.getProperty("username")); 

         try { 
          u.setTimezone(((Double) user 
            .getProperty("timezone")).intValue()); 
         } catch (Exception e) { 
         } 

         KlyphSession.setSessionUser(u); 

         if (getActivity() != null) { 
          ((LoginFragmentCallBack) getActivity()) 
            .onUserInfoFetched(u); 
         } 
        } 
       } 
      }); 

    authButton.setFragment(this); 

    return view; 
} 

private void onSessionStateChange(Session session, SessionState state, 
     Exception exception) { 
    if (getView() != null) { 
     if (state.isOpened()) { 
      authButton.setVisibility(View.GONE); 
      progressBar.setVisibility(View.VISIBLE); 
     } else if (state.isClosed()) { 
      authButton.setVisibility(View.VISIBLE); 
      progressBar.setVisibility(View.GONE); 
     } 
    } 
} 

@Override 
public void onAttach(Activity activity) { 
    super.onAttach(activity); 

    if (!(activity instanceof LoginFragmentCallBack)) { 
     throw new Error("Activity must implements LoginFragmentCallBack"); 
    } 
} 

@Override 
public void onResume() { 
    super.onResume(); 

    Session session = Session.getActiveSession(); 
    if (session != null && (session.isOpened() || session.isClosed())) { 
     onSessionStateChange(session, session.getState(), null); 
    } 

    uiHelper.onResume(); 
} 

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

@Override 
public void onPause() { 
    super.onPause(); 
    uiHelper.onPause(); 
} 

@Override 
public void onDestroy() { 
    super.onDestroy(); 
    uiHelper.onDestroy(); 
    uiHelper = null; 
    authButton = null; 
    progressBar = null; 
    callback = null; 
} 

@Override 
public void onSaveInstanceState(Bundle outState) { 
    super.onSaveInstanceState(outState); 
    uiHelper.onSaveInstanceState(outState); 
} 

}

+0

這是我的項目中的代碼 –

相關問題