如何在Facebook开发人员的测试应用程序上运行Android应用程序

时间:2015-02-05 04:08:52

标签: android facebook facebook-graph-api

大家好,我是一个关于与facebook sdk合作的新手。

我已经在facebook开发人员中创建了一个应用程序,添加了包,密钥哈希......然后我创建了一个测试应用程序来测试我的应用程序。 但是当我运行我的项目时,在我的设备上运行app,它无法登录以获取数据。

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开发人员中为测试应用添加权限的位置

1 个答案:

答案 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);
}

}