2014-11-20 92 views
0

我试图将Twitter集成到我的应用程序中(即使您从未这样做过,请继续阅读)。这是登录流程:活动打开外部应用程序,打开活动,从而使其在活动堆栈中翻倍

  1. 用户点击活动
  2. Twitter的认证网站在浏览器中出现“与Twitter登录”。用户点击允许应用使用Twitter
  3. 浏览器消失,活动再次打开。

问题是,活动打开AGAIN,这意味着点击后我仍然在这个活动(就在用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); 

任何想法?

回答

0

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

还可以使用此:

intent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_CLEAR_TOP);