【问题标题】:The activity doesn't go back to the previous one (using facebook sdk)活动不会回到前一个活动(使用 facebook sdk)
【发布时间】:2015-04-10 03:18:37
【问题描述】:

我正在使用 facebook sdk 来允许用户使用他们的 facebook 帐户登录我的应用程序,我正在使用一个在登录访问后启动其他活动的片段,它工作正常。问题是这个活动不会回到之前的活动。 Facebook SDK 4.0 使用在 SDK 中实现的其他活动并处理登录,它是否与此问题有关。 我正在使用的代码:

@Override
public void onResume() {
    super.onResume();
    profileTracker.startTracking();
    tokenTracker.startTracking();
    Profile profile = Profile.getCurrentProfile();
    if (profile != null) {
        Intent intent = new Intent(getActivity(), PlayingActivity.class);
        getActivity().startActivity(intent);
    }
}

【问题讨论】:

    标签: android facebook android-intent fragment


    【解决方案1】:

    不要onResume() 中启动活动,因为每次返回活动时,都会调用onResume(),如果配置文件不为空,则会启动 PlayingActivity。

    将以下代码移至其他地方,

    Profile profile = Profile.getCurrentProfile();
    if (profile != null) {
        Intent intent = new Intent(getActivity(), PlayingActivity.class);
        getActivity().startActivity(intent);
    }
    

    Click to learn more about the Activity Lifecycle.

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-09-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-04-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多