活动打开外部应用程序,打开活动,从而使活动堆栈中的活动倍增

时间:2014-11-20 18:28:25

标签: android android-activity twitter

我正在尝试将Twitter集成到我的应用程序中(即使您从未这样做过,请进一步阅读)。这是登录工作流程:

  1. 用户点击"使用Twitter登录"在活动中
  2. Twitter认证网站出现在浏览器中。用户点击允许该应用使用Twitter
  3. 浏览器消失,活动再次打开。
  4. 问题是该活动打开了AGAIN,这意味着点击BACK后我仍然在这个活动中(在用Twitter登录之前),所以我需要再次点击BACK。

    这是在浏览器中打开Twitter授权网站的行:

    SettingsActivity.this.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(requestToken.getAuthenticationURL())));
    

    finish()放在后面没有帮助。

    甚至没有设置FLAG_ACTIVITY_CLEAR_TOP:

      Intent intent = new Intent(Intent.ACTION_VIEW);
      intent.setData(Uri.parse(requestToken.getAuthenticationURL()));
      intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
      startActivity(intent);
    

    有什么想法吗?

1 个答案:

答案 0 :(得分:0)

您是否在清单中设置了活动android:launchMode="singleInstance"

也可以使用:

intent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_CLEAR_TOP);
相关问题